VB小游戏代码

合集下载
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

用VB程序做打字练习小游戏221.196.240.* 1楼

求求各位VB高手帮帮我,实在是十万火急,不胜感激!
E-mail/MSN:nuanss_5@



0


2005-9-9 19:34 回复
221.203.126.* 2楼

Option Explicit
Dim score As Integer
Dim speed As Integer

Sub init()
Label1.Caption = Chr(Int(Rnd * 26) + 49)
speed = Int(Rnd * 100 + 100)
Label1.Left = Int(Rnd * Frame1.Width)
Label1.Top = Frame1.Top
End Sub

Sub init1()
Label6.Caption = Chr(Int(Rnd * 26) + 97)
speed = Int(Rnd * 100 + 100)
Label6.Left = Int(Rnd * Frame1.Width)
Label6.Top = Frame1.Top
End Sub

Private Sub Command1_Click()
init
Timer1.Enabled = True
Timer2.Enabled = True
Command1.Visible = False
Label5.Caption = 200
Label4.Caption = 0
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) = Label1.Caption Then
init
score = score + 1
Label4.Caption = score
End If
If Chr(KeyAscii) = Label6.Caption Then
init1
score = score + 1
Label4.Caption = score
End If
End Sub

Private Sub Form_Load()
Randomize
Timer1.Enabled = False
Timer2.Enabled = False
End Sub

Private Sub Timer1_Timer()
Label1.Top = Label1.Top + speed
If Label1.Top > Frame1.Height Then
init
End If
Label6.Top = Label6.Top + speed
If Label6.Top > Frame1.Height Then
init1
End If
End Sub

Private Sub Timer2_Timer()
Label5.Caption = Val(Label5.Caption) - 1
If Val(Label5.Caption) <= 0 Then
Timer1.Enabled = False
Label1.Caption = ""
Label6.Caption = ""
Select Case score
Case Is <= 80
MsgBox vbCrLf + "Don't give up,try again!"
Case Is < 200
MsgBox vbCrLf + "That's right. Come on!"
Case Is < 350
MsgBox vbCrLf + "Continue and you will be top gun!"
Case Is > 350
MsgBox vbCrLf + "Congraduation! You have been a top gun!"
End Select
Command1.Visible = True
Label4.Caption = 0
Label5.Caption = 200
Timer1.Enabled = False
Timer2.Enabled = False
End If
End Sub



相关文档
最新文档