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

上传人:夏** 文档编号:507499551 上传时间:2023-09-01 格式:DOC 页数:3 大小:27.50KB
返回 下载 相关 举报
VB程序代码(简单小程序)_第1页
第1页 / 共3页
VB程序代码(简单小程序)_第2页
第2页 / 共3页
VB程序代码(简单小程序)_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

《VB程序代码(简单小程序)》由会员分享,可在线阅读,更多相关《VB程序代码(简单小程序)(3页珍藏版)》请在金锄头文库上搜索。

1、.实验一:(带有进度条的倒计时程序)PublicClass Form1Dim timersAs IntegerDim tempAs IntegerPrivateSub Timer1_Tick(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles Timer1.TickIf(ProgressBar1.Value+ ProgressBar1.Maximum/ timers ProgressBar1.Maximum)ThenProgressBar1.Value += ProgressBar1.Maximum / timer

2、sElseTimer1.Enabled =FalseProgressBar1.Value = ProgressBar1.MaximumMessageBox.Show( 进度完成! )End Iftemp += 1Label1.Text = temp.ToString()End SubPrivateSub Form1_Load( ByVal sender As System.Object,ByVal e As System.EventArgs)HandlesMyBase.Loadtimers = 30End SubPrivate Sub Button2_Click( ByVal sender A

3、s System.Object, ByVal e As System.EventArgs) Handles Button2.Clicktimers = Val(InputBox( 输入 , 请输入总时间。 , 30, 0, 0)End SubPrivate Sub Button1_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickTimer1.Enabled =TrueEnd SubEnd Class实验二(定时器控制蝴蝶飞舞)PublicClass Form1Dim

4、tAs IntegerPrivateSub Timer1_Tick(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles Timer1.TickDim t As Boolean If t = True Then PictureBox3.Image = PictureBox2.Image t = FalseElse1 / 3. PictureBox3.Image = PictureBox1.Image t = TrueEnd IfSelectCase tCase 0PictureBox3.Image = Picture

5、Box1.Imaget = 1Case 1PictureBox3.Image = PictureBox2.Imaget = 2Case 2PictureBox3.Image = PictureBox1.Imaget = 3Case 3PictureBox3.Image = PictureBox1.Imaget = 0End SelectEnd SubEnd Class实验三(递推法迭代法 - 猴子吃桃)PublicClass Form1PrivateSub Button1_Click(ByVal senderAs System.Object,ByVal eAsSystem.EventArgs)

6、Handles Button1.ClickDim n, yAs Integern = Val(TextBox1.Text)y = Val(TextBox2.Text)Dim xiAs Doublexi = yTextBox3.Text = 第 + n.ToString() + 天的桃子为: + y.ToString() + 个。 + vbCrLfFor iAs Integer= n - 1To 1Step -1xi = (xi + 1) * 2TextBox3.Text += 第 + i.ToString() + 天的桃子为: + xi.ToString() + 个。 + vbCrLf Nex

7、tEnd SubEnd Class2 / 3.实验四(加减乘除随机数题)PublicClass Form1Dim x, yAs IntegerDim iAs IntegerDim sum As IntegerPrivate Sub Button2_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.ClickIf(Label1.Text )ThenTextBox2.Text += Label1.Text + TextBox1.TextTextBox2.Text +=结果 If(su

8、m = Val(TextBox1.Text)ThenTextBox2.Text += + vbCrLfElseTextBox2.Text += + vbCrLfEnd IfEnd IfRandomize()x = Int(Rnd() * 999 + 1)y = Int(Rnd() * 999 + 1)i = Int(Rnd() * 4 + 1)SelectCase iCase 1Label1.Text = x.ToString() + + y.ToString() + sum = x + yCase 2Label1.Text = x.ToString() + + y.ToString() + sum = x - yCase 3Label1.Text = x.ToString() + + y.ToString() + sum = x * yCase 4Label1.Text = x.ToString() + + y.ToString() + sum = x / yEnd SelectEnd SubEnd Class3 / 3

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 演讲稿/致辞

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号