有没有vb编写打字游戏的源代码啊

 我来答
383163155
2011-03-26 · 超过21用户采纳过TA的回答
知道答主
回答量:72
采纳率:0%
帮助的人:0
展开全部
Dim score As Integer
Dim speed As Integer
Dim typetime As Integer

Private Sub init()
Randomize

lblletter1.Caption = Chr(Int(Rnd * 42) + 48)
lblletter1.Left = Int(Rnd * 2800) + 1
lblletter1.Top = 0

End Sub

Private Sub init1()
Randomize
lblletter2.Caption = Chr(Int(Rnd * 25) + 97)
lblletter2.Left = Int(Rnd * 2800) + 1
lblletter2.Top = 0

End Sub

Private Sub Command1_Click()
score = Int(lblscore.Text)
init
init1
Timer1 = True
Timer2 = True
HScroll1.Enabled = False
Command1.Enabled = False
Command2.Enabled = False
HScroll1.Enabled = False

If lbltime.Text <= 0 Then
Timer1 = False
Timer2 = False
lblletter1.Caption = ""
lblletter2.Caption = ""
End If

End Sub

Private Sub Command2_Click()
typetime = InputBox("请输入打字时间。", "时间设置")
If typetime <= 0 Then
lbltime.Text = 60
End If
lbltime.Text = typetime
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) = lblletter1.Caption Then

score = score + 1
lblscore.Text = score
init
End If
If Chr(KeyAscii) = lblletter2.Caption Then
score = score + 1
lblscore.Text = score
init1
End If
End Sub

Private Sub Form_Load()
Timer1.Enabled = False
Timer2.Enabled = False
lblletter1.AutoSize = True
lblletter2.AutoSize = True
lblletter1.Caption = ""
lblletter2.Caption = ""
lblscore.Text = 0
lblspeed.Caption = 100
lbltime.Text = 60
HScroll1.Max = 200
HScroll1.Min = 20
HScroll1.SmallChange = 5
HScroll1.LargeChange = 20
HScroll1.Value = 100
End Sub

Private Sub HScroll1_Change()
lblspeed.Caption = HScroll1.Value
End Sub

Private Sub Timer1_Timer()
lblletter1.Top = lblletter1.Top + lblspeed.Caption
If lblletter1.Top >= 4335 Then
Call init
End If
lblletter2.Top = lblletter2.Top + lblspeed.Caption
If lblletter2.Top >= 4335 Then
Call init1
End If
End Sub

Private Sub Timer2_Timer()
If lbltime.Text > 0 Then
lbltime.Text = lbltime.Text - 1

Else: Select Case score / (typetime / 60)
Case Is <= 40
MsgBox ("不要放弃再试一次!")
Case 40 To 80
MsgBox ("太棒了,继续努力!")
Case 80 To 120
MsgBox ("坚持下去,你将成为一个打字高手!")
Case Is > 120
MsgBox ("祝贺你!你已经是一个打字高手!")
End Select
Timer1 = False
Timer2 = False
HScroll1.Enabled = True
Command1.Enabled = True
Command2.Enabled = True
HScroll1.Enabled = True
init
init1
End If

End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式