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

上传人:yyf 文档编号:6276516 上传时间:2020-10-11 格式:DOC 页数:4 大小:27KB
返回 下载 相关 举报
VB程序代码(简单小程序).doc_第1页
第1页 / 共4页
VB程序代码(简单小程序).doc_第2页
第2页 / 共4页
VB程序代码(简单小程序).doc_第3页
第3页 / 共4页
VB程序代码(简单小程序).doc_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

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

1、.实验一:(带有进度条的倒计时程序)Public Class Form1 Dim timers As Integer Dim temp As Integer Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick If (ProgressBar1.Value + ProgressBar1.Maximum / timers ProgressBar1.Maximum) Then ProgressBar1.Value += ProgressBar1.

2、Maximum / timers Else Timer1.Enabled = False ProgressBar1.Value = ProgressBar1.Maximum MessageBox.Show(进度完成!) End If temp += 1 Label1.Text = temp.ToString() End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load timers = 30 End Sub Private Sub

3、Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click timers = Val(InputBox(输入, 请输入总时间。, 30, 0, 0) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Timer1.Enabled = True End SubEnd Class实验二(定

4、时器控制蝴蝶飞舞)Public Class Form1 Dim t As Integer Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim t As Boolean If t = True Then精品. PictureBox3.Image = PictureBox2.Image t = False Else PictureBox3.Image = PictureBox1.Image t = True End If Select

5、Case t Case 0 PictureBox3.Image = PictureBox1.Image t = 1 Case 1 PictureBox3.Image = PictureBox2.Image t = 2 Case 2 PictureBox3.Image = PictureBox1.Image t = 3 Case 3 PictureBox3.Image = PictureBox1.Image t = 0 End Select End SubEnd Class实验三(递推法 迭代法-猴子吃桃)Public Class Form1 Private Sub Button1_Click(

6、ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim n, y As Integer n = Val(TextBox1.Text) y = Val(TextBox2.Text) Dim xi As Double xi = y TextBox3.Text = 第 + n.ToString() + 天的桃子为: + y.ToString() + 个。 + vbCrLf For i As Integer = n - 1 To 1 Step -1 xi = (xi + 1) * 2 T

7、extBox3.Text += 第 + i.ToString() + 天的桃子为: + xi.ToString() + 个。 + vbCrLf Next精品. End SubEnd Class实验四(加减乘除随机数题)Public Class Form1 Dim x, y As Integer Dim i As Integer Dim sum As Integer Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If (Labe

8、l1.Text ) Then TextBox2.Text += Label1.Text + TextBox1.Text TextBox2.Text += 结果 If (sum = Val(TextBox1.Text) Then TextBox2.Text += + vbCrLf Else TextBox2.Text += + vbCrLf End If End If Randomize() x = Int(Rnd() * 999 + 1) y = Int(Rnd() * 999 + 1) i = Int(Rnd() * 4 + 1) Select Case i Case 1 Label1.Text = x.ToString() + + y.ToString() + sum = x + y Case 2 Label1.Text = x.ToString() + + y.ToString() + sum = x - y Case 3 Label1.Text = x.ToString() + + y.ToString() + sum = x * y Case 4 Label1.Text = x.ToString() + + y.ToString() + sum = x / y精品. End Select End SubEnd Class如有侵权请联系告知删除,感谢你们的配合!精品

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 科普知识


经营许可证编号:宁ICP备18001539号-1