人人都会用的VB游戏小程序代码3.球来回弹在窗体上添加一shape空间,shape为circle,计时器空间inteval=10通用DimbzPrivateSubTimer1_Timer()IfShape1.Left=Form1.ScaleWidth-Shape1.WidthThenbz=1IfShape1.Left=0Thenbz=0Ifbz=0ThenShape1.Left=Shape1.Left+10Ifbz=1ThenShape1.Left=Shape1.Left-10EndSub注意:bz的使用(bz为一临时标志,用于判断移动方向)2.六角星Dimi%,j%,k%Fori=1To10Ifi4Ori6ThenPrintSpace(20-i);Forj=1ToiPrint○;NextjElsePrintSpace(6+i);Fork=14-iTo1Step-1Print○;NextkEndIfPrintNextiFori=3To1Step-1PrintSpace(20-i);Forj=1ToiPrint○;NextjPrintNexti1.空心三角形Dimi%,j%PrintSpace(20);*Fori=2To9PrintSpace(21-i);*;Space(2*i-3);*NextPrintSpace(10);Fori=1To10PrintSpace(1);*;Next扩展程序Constn=15Dima(1Ton)AsIntegerDimi%,j%,t%RandomizeFori=1Tona(i)=Int(100*Rnd)'生成15个0~100的随机整数存入数组NextPrint排序前:Fori=1TonPrinta(i);NextPrintFori=1Ton-1Forj=i+1TonIfa(j)a(i)Thent=a(j):a(j)=a(i):a(i)=tNextNextPrint排序后:Fori=1TonPrinta(i);Next3.球来回弹在窗体上添加一shape空间,shape为circle,计时器空间inteval=10通用DimbzPrivateSubTimer1_Timer()IfShape1.Left=Form1.ScaleWidth-Shape1.WidthThenbz=1IfShape1.Left=0Thenbz=0Ifbz=0ThenShape1.Left=Shape1.Left+10Ifbz=1ThenShape1.Left=Shape1.Left-10EndSub注意:bz的使用(bz为一临时标志,用于判断移动方向)4.从大到小再从小到大变化在窗体添加一标签label1,autosize=true,caption=★,添加一计时器空间timer1,inteval=100通用:DimbzPrivateSubTimer1_Timer()IfLabel1.FontSize=72Thenbz=1IfLabel1.FontSize=8Thenbz=0Ifbz=0ThenLabel1.FontSize=Label1.FontSize+2Ifbz=1ThenLabel1.FontSize=Label1.FontSize-2EndSub5.在VB中用画圆Dimx,y,iAsSingleClsScale(-15,15)-(15,-15)'定义笛卡儿坐标系Fori=0To6.28Step0.05y=10*Sin(i)x=10*Cos(i)CurrentX=xCurrentY=yPrint*Next6.四周循环移动创建一个窗体,在上面添加“开始”和“停止”两个按钮,添加一个计时器控件timer1在窗体上添加一个shape控件,设置背景不透明,红色,调整大小程序代码如下:OptionExplicitDimbz%PrivateSubCommand1_Click()'开始按钮Timer1=TrueEndSubPrivateSubCommand2_Click()'停止按钮Timer1=FalseEndSubPrivateSubForm_Load()Shape1.Left=0Shape1.Top=0Timer1=FalseTimer1.Interval=10EndSubPrivateSubTimer1_Timer()IfShape1.Left>=Form1.ScaleWidth-Shape1.WidthAndShape1.Top<=0Thenbz=1IfShape1.Top>=Form1.ScaleHeight-Shape1.HeightThenbz=2IfShape1.Left<=0Thenbz=3IfShape1.Top<=0AndShape1.Left<=0Thenbz=0SelectCasebzCase0Shape1.Left=Shape1.Left+10Case1Shape1.Top=Shape1.Top+10Case2Shape1.Left=Shape1.Left-10Case3Shape1.Top=Shape1.Top-10EndSelectEndSub