做一个vb程序 打字游戏

2024-12-03 18:10:34
推荐回答(2个)
回答1:

以前做过一个 好像在我网盘里面有 叫type!~

网盘地址在我个人资料里!~

Option Explicit
Dim score As Integer
Dim speed As Integer
Dim Wrong As Integer

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

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

Private Sub Form_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) = Label1.Caption Then
init
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
End Sub

Private Sub Timer2_Timer()
Label5.Text = Val(Label5.Text) - 1

If Val(Label5.Text) <= 0 Then
Timer1.Enabled = False

Label1.Caption = ""

MsgBox (score / Wrong) * 100 & "%"

Command1.Visible = True

Label4.Caption = 0
Label5.Text = 60

Label5.Enabled = True
Label7.Enabled = True

Timer1.Enabled = False
Timer2.Enabled = False
End If
End Sub

控件自己加!~

回答2:

城市学院的?你要是弄完了,给我传过来谢谢,Q824680394