如何使用VB编写一个简单的小程序
3个回答
展开全部
Dim sec, min, h
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
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
展开全部
打开vb,选择新建工程,标准exe,点击运行启动,就看见一个窗体。
这就是最简单的vb程序。
然后点击运行结束,视图,代码窗口,粘贴如下代码:
Private Sub Form_Load()
MsgBox ("你好!")
End Sub
点击运行启动,就看到一个新的效果
祝你成功!
这就是最简单的vb程序。
然后点击运行结束,视图,代码窗口,粘贴如下代码:
Private Sub Form_Load()
MsgBox ("你好!")
End Sub
点击运行启动,就看到一个新的效果
祝你成功!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
打开VB,编写,生成
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询