VB程序代码简单小程序
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
V B程序代码简单小程
序
集团标准化工作小组 [Q8QX9QT-X8QQB8Q8-NQ8QJ8-M8QMN]
实验一(带有进度条的倒计时程序)
Public Class Form1
Dim timers As Integer
Dim temp As Integer
Private Sub Timer1_Tick(ByVal sender As , ByVal e As Handles If + / timers < Then
+= / timers
Else
= False
=
("进度完成!")
End If
temp += 1
= ()
End Sub
Private Sub Form1_Load(ByVal sender As , ByVal e As Handles
timers = 30
End Sub
Private Sub Button2_Click(ByVal sender As , ByVal e As Handles timers = Val(InputBox("输入", "请输入总时间。", 30, 0, 0)) End Sub
Private Sub Button1_Click(ByVal sender As , ByVal e As Handles = True
End Sub
End Class
实验二(定时器控制蝴蝶飞舞)
Public Class Form1
Dim t As Integer
Private Sub Timer1_Tick(ByVal sender As , ByVal e As Handles ’Dim t As Boolean
' If t = True Then
' =
' t = False
'Else
' =
' t = True
'End If
Select Case t
Case 0
=
t = 1
Case 1
=
t = 2
Case 2
=
t = 3
Case 3
=
t = 0
End Select
End Sub
End Class
实验三(递推法迭代法--猴子吃桃)
Public Class Form1
Private Sub Button1_Click(ByVal sender As , ByVal e As Handles Dim n, y As Integer
n = Val
y = Val
Dim xi As Double
xi = y
= "第" + () + "天的桃子为:" + () + "个。" + vbCrLf For i As Integer = n - 1 To 1 Step -1
xi = (xi + 1) * 2
+= "第" + () + "天的桃子为:" + () + "个。" + vbCrLf Next
End Sub
End Class
实验四(加减乘除随机数题)
Public Class Form1
Dim x, y As Integer
Dim i As Integer
Dim sum As Integer
Private Sub Button2_Click(ByVal sender As , ByVal e As Handles If <> "") Then
+= +
+= " 结果"
If (sum = Val) Then
+= "√" + vbCrLf
Else
+= "×" + 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
= () + "+" + () + "="
sum = x + y
Case 2
= () + "-" + () + "="
sum = x - y
Case 3
= () + "×" + () + "="
sum = x * y
Case 4
= () + "÷" + () + "="
sum = x / y
End Select
End Sub
End Class
谢谢大家!!!!!!