VB程序代码(简单小程序)-.pdf

上传人:索**** 文档编号:76239440 上传时间:2023-03-08 格式:PDF 页数:3 大小:18.52KB
返回 下载 相关 举报
VB程序代码(简单小程序)-.pdf_第1页
第1页 / 共3页
VB程序代码(简单小程序)-.pdf_第2页
第2页 / 共3页
点击查看更多>>
资源描述

《VB程序代码(简单小程序)-.pdf》由会员分享,可在线阅读,更多相关《VB程序代码(简单小程序)-.pdf(3页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、实验一:(带有进度条的倒计时程序)PublicClass Form1 Dim timers As Integer Dim temp As Integer PrivateSub 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.Maximum/timer

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

3、stem.Object,ByVal e AsSystem.EventArgs)Handles Button2.Click timers=Val(InputBox(输入 ,请输入总时间。,30,0,0)End Sub PrivateSub Button1_Click(ByVal sender As System.Object,ByVal e AsSystem.EventArgs)Handles Button1.Click Timer1.Enabled=True End Sub End Class 实验二(定时器控制蝴蝶飞舞)PublicClass Form1 Dim t As Integer P

4、rivateSub 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 SelectCase t Case 0 PictureBox3.Image=PictureBox1.Image t=1 Case 1 Pi

5、ctureBox3.Image=PictureBox2.Image t=2 Case 2 PictureBox3.Image=PictureBox1.Image t=3 Case 3 PictureBox3.Image=PictureBox1.Image t=0 End Select End Sub End Class 实验三(递推法迭代法-猴子吃桃)PublicClass Form1 PrivateSub Button1_Click(ByVal sender As System.Object,ByVal e AsSystem.EventArgs)Handles Button1.Click D

6、im 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 TextBox3.Text+=第 +i.ToString()+天的桃子为:+xi.ToString()+个。+vbCrLf Next End Sub End Class 实验四(加减乘除随机数题)PublicClass Form

7、1 Dim x,y As Integer Dim i As Integer Dim sum As Integer PrivateSub Button2_Click(ByVal sender As System.Object,ByVal e AsSystem.EventArgs)Handles Button2.Click If (Label1.Text )Then TextBox2.Text+=Label1.Text+TextBox1.Text TextBox2.Text+=结果 If (sum=Val(TextBox1.Text)Then TextBox2.Text+=+vbCrLf Else

8、 TextBox2.Text+=+vbCrLf End If End If Randomize()x=Int(Rnd()*999+1)y=Int(Rnd()*999+1)i=Int(Rnd()*4+1)SelectCase 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 Sub End Class

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

当前位置:首页 > 技术资料 > 实施方案

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁