资源描述
VB趣味小程序1. 空心三角形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个0100的随机整数存入数组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);2. Next六角星Dimi%,j%,k%Fori=1To10Ifi6ThenPrintSpace(20-i);Forj=1ToiPrintO;NextjElsePrintSpace(6+i);Fork=14-iTo1Step-1PrintO;NextkEndIfPrintNextiFori=3To1Step-1PrintSpace(20-i);Forj=1ToiPrintO;NextjPrintNexti球来回弹在窗体上添加一shape空间,shape为circle,计时器空间inteval=10通用DimbzPrivateSubTimer1_Timer()IfShape1.Left=Form1.ScaleWidth-Shape1.WidthThenbz=1IfShape1.Left=72Thenbz=1IfLabel1.FontSize=8Thenbz=0Ifbz=0ThenLabel1.FontSize=Label1.FontSize+23. Ifbz=1ThenLabel1.FontSize=Label1.FontSize-2EndSub在VB中用画圆Dimx,y,iAsSingleClsScale(-15,15)-(15,-15)定义笛卡儿坐标系Fori=0To6.28Step0.05y=10*Sin(i)x=10*Cos(i)CurrentX=xCurrentY=yPrint*Next6.四周循环移动创建一个窗体,在上面添加“开始”和“停止”两个按钮,添加一个计时器控件在窗体上添加一个shape控件,设置背景不透明,红色,调整大小程序代码如下:OptionExplicitDimbz%timer1PrivateSubCommand1_Click()Timer1=True开始按钮EndSubPrivateSubCommand2_Click()Timer1=False停止按钮EndSubPrivateSubForm_Load()Shape1.Left=0Shape1.Top=0Timer1=FalseTimer1.Interval=10EndSubPrivateSubTimer1_Timer()Shape1.TopIfShape1.Left>=Form1.ScaleWidth-Shape1.WidthAnd<=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-10EndSelectEndSubTHANKS!学习课件等等致力为企业和个人提供合同协议,策划案计划书,打造全网一站式需求欢迎您的下载,资料仅供参考
展开阅读全文