VB程序代码(简单小程序)

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

实验一:(带有进度条的倒计时程序)PublicClassForm1DimtimersAsIntegerDimtempAsIntegerPrivateSubTimer1_Tick(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesTimer1.TickIf(ProgressBar1.Value+ProgressBar1.Maximum/timersProgressBar1.Maximum)ThenProgressBar1.Value+=ProgressBar1.Maximum/timersElseTimer1.Enabled=FalseProgressBar1.Value=ProgressBar1.MaximumMessageBox.Show(进度完成!)EndIftemp+=1Label1.Text=temp.ToString()EndSubPrivateSubForm1_Load(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.Loadtimers=30EndSubPrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.Clicktimers=Val(InputBox(输入,请输入总时间。,30,0,0))EndSubPrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickTimer1.Enabled=TrueEndSubEndClass实验二(定时器控制蝴蝶飞舞)PublicClassForm1DimtAsIntegerPrivateSubTimer1_Tick(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesTimer1.Tick’DimtAsBoolean'Ift=TrueThen'PictureBox3.Image=PictureBox2.Image't=False'Else'PictureBox3.Image=PictureBox1.Image't=True'EndIfSelectCasetCase0PictureBox3.Image=PictureBox1.Imaget=1Case1PictureBox3.Image=PictureBox2.Imaget=2Case2PictureBox3.Image=PictureBox1.Imaget=3Case3PictureBox3.Image=PictureBox1.Imaget=0EndSelectEndSubEndClass实验三(递推法迭代法--猴子吃桃)PublicClassForm1PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDimn,yAsIntegern=Val(TextBox1.Text)y=Val(TextBox2.Text)DimxiAsDoublexi=yTextBox3.Text=第+n.ToString()+天的桃子为:+y.ToString()+个。+vbCrLfForiAsInteger=n-1To1Step-1xi=(xi+1)*2TextBox3.Text+=第+i.ToString()+天的桃子为:+xi.ToString()+个。+vbCrLfNextEndSubEndClass实验四(加减乘除随机数题)PublicClassForm1Dimx,yAsIntegerDimiAsIntegerDimsumAsIntegerPrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.ClickIf(Label1.Text)ThenTextBox2.Text+=Label1.Text+TextBox1.TextTextBox2.Text+=结果If(sum=Val(TextBox1.Text))ThenTextBox2.Text+=√+vbCrLfElseTextBox2.Text+=×+vbCrLfEndIfEndIfRandomize()x=Int(Rnd()*999+1)y=Int(Rnd()*999+1)i=Int(Rnd()*4+1)SelectCaseiCase1Label1.Text=x.ToString()+++y.ToString()+=sum=x+yCase2Label1.Text=x.ToString()+-+y.ToString()+=sum=x-yCase3Label1.Text=x.ToString()+×+y.ToString()+=sum=x*yCase4Label1.Text=x.ToString()+÷+y.ToString()+=sum=x/yEndSelectEndSubEndClass

1 / 3
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功