欢迎来到天天文库
浏览记录
ID:39976432
大小:36.50 KB
页数:3页
时间:2019-07-16
《VB程序代码(简单小程序)》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、实验一(带有进度条的倒计时程序)PublicClassForm1DimtimersAsIntegerDimtempAsIntegerPrivateSubTimer1_Tick(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesTimer1.TickIf(ProgressBar1.Value+ProgressBar1.Maximum/timers2、ersElseTimer1.Enabled=FalseProgressBar1.Value=ProgressBar1.MaximumMessageBox.Show("进度完成!")EndIftemp+=1Label1.Text=temp.ToString()EndSubPrivateSubForm1_Load(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.Loadtimers=30EndSubPrivateSubButton2_Click(ByValsenderA3、sSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.Clicktimers=Val(InputBox("输入","请输入总时间。",30,0,0))EndSubPrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickTimer1.Enabled=TrueEndSubEndClass实验二(定时器控制蝴蝶飞舞)PublicClassForm1DimtAsInt4、egerPrivateSubTimer1_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=1Ca5、se1PictureBox3.Image=PictureBox2.Imaget=2Case2PictureBox3.Image=PictureBox1.Imaget=3Case3PictureBox3.Image=PictureBox1.Imaget=0EndSelectEndSubEndClass实验三(递推法迭代法--猴子吃桃)PublicClassForm1PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.Cli6、ckDimn,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实验四(加减乘除随机数题)Publi7、cClassForm1Dimx,yAsIntegerDimiAsIntegerDimsumAsIntegerPrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.ClickIf(Label1.Text<>"")ThenTextBox2.Text+=Label1.Text+TextBox1.TextTextBox2.Text+="结果"If(sum=Val(TextBox1.Text))ThenTextBox2.Text+=8、"√"+vbCrLfElseTextBox2.Text+="×"+vbCrLfEndIfEndIfRandomize()x
2、ersElseTimer1.Enabled=FalseProgressBar1.Value=ProgressBar1.MaximumMessageBox.Show("进度完成!")EndIftemp+=1Label1.Text=temp.ToString()EndSubPrivateSubForm1_Load(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.Loadtimers=30EndSubPrivateSubButton2_Click(ByValsenderA
3、sSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.Clicktimers=Val(InputBox("输入","请输入总时间。",30,0,0))EndSubPrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickTimer1.Enabled=TrueEndSubEndClass实验二(定时器控制蝴蝶飞舞)PublicClassForm1DimtAsInt
4、egerPrivateSubTimer1_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=1Ca
5、se1PictureBox3.Image=PictureBox2.Imaget=2Case2PictureBox3.Image=PictureBox1.Imaget=3Case3PictureBox3.Image=PictureBox1.Imaget=0EndSelectEndSubEndClass实验三(递推法迭代法--猴子吃桃)PublicClassForm1PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.Cli
6、ckDimn,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实验四(加减乘除随机数题)Publi
7、cClassForm1Dimx,yAsIntegerDimiAsIntegerDimsumAsIntegerPrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.ClickIf(Label1.Text<>"")ThenTextBox2.Text+=Label1.Text+TextBox1.TextTextBox2.Text+="结果"If(sum=Val(TextBox1.Text))ThenTextBox2.Text+=
8、"√"+vbCrLfElseTextBox2.Text+="×"+vbCrLfEndIfEndIfRandomize()x
此文档下载收益归作者所有