Private Sub Command1_Click()
Timer1.Enabled = True
h = Text1.Text
min = Text2.Text
sec = Text3.Text
Timer2.Enabled = False
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
Form1.BackColor = &HFFFF00
Timer1.Enabled = False
Timer1.Interval = 1000
Timer2.Enabled = True
Timer2.Interval = 1000
Text1.Text = 2
Text2.Text = "00"
Text3.Text = "00"轮握
Command2.Caption = "腊册庆退出"
Command1.Caption = "开始倒计时"姿罩
End Sub
Private Sub Timer1_Timer()
If sec >0 Then
sec = sec - 1
Else:
If (min >0 Or h >0) Then
sec = 59
End If
If min >0 Then
min = min - 1
Else:
If h >0 Then
min = 59
End If
If h >0 Then
h = h - 1
Else: Timer1.Enabled = False
CreateObject("SAPI.SpVoice").Speak "GAME OVER!"
Form1.BackColor = &HFF
End If
End If
End If
Text1.Text = h
Text2.Text = min
Text3.Text = sec
Label6.Caption = Now
End Sub
Private Sub Timer2_Timer()
Label6.Caption = Now
End Sub
1. 用VB新建镇哪一个此橘标准EXE程序
2. 用 Lable 、TextBox 和 CommandButton 控件在窗体中设计界面如下:
3. 双击“抽取”按钮,并在代码窗御扒码口中修改代码如下:
Private Sub Command1_Click()
Dim v1 As Long, v2 As Long, v3 As Long
v1 = Val(Text1)
v2 = Val(Text2)
v3 = Int(Rnd(1) * (v2 - v1 + 1)) + v1
Text3.Text = v3
End Sub
4.按F5运行,并进行测试即可
Dim a, bPrivate Sub Command1_Click()
End
End Sub
Private Sub Form_Load()
Text.Text = "Visual Basic程序设计"唯仔冲
Command1.Caption = "指歼结束"
Text.Left = 0: Text.Top = 0: Text.Width = 0.5 * Form1.Width
Text.Height = 0.5 * Form1.Height
a = Form1.Width - Command1.Left
b = Form1.Height - Command1.Top
End Sub
Private Sub Form_Resize()
Text.Left = 0: Text.Top = 0: Text.Width = 0.5 * Form1.Width
Text.Height = 0.5 * Form1.Height
Command1.Left = Form1.Width - a
Command1.Top = Form1.Height - b
End Sub
注意,各变戚神量名,控件名保持一致,你题目中的文本框名称为text
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)