VB指法练习的小游戏

VB指法练习的小游戏|课程设计|计算机数据库课程设计

Dim sSource(180), sInput(180)

    '分别定义用于存储用户输入和原始文本的字符数组

    Dim i As Integer, iCorrect As Integer, iSecond As Integer

    'iCorrect用于记录用户输入正确的字符数

    'iSecond用于记录已经用去的时间

    Dim n As Integer

    

Private Sub command1_Click()     '提示用户输入用户名

If (Text5.Text = "") Then

MsgBox ("请输入姓名:")

Else

Command2.Enabled = True

Command1.Enabled = False

End If

End Sub

 

Private Sub Command2_Click()   '对用户输入数据进行统计

Command1.Enabled = True

Command2.Enabled = False

iCorrect = 0

 

For i = 1 To 60

sInput(i) = Mid(Text1.Text, i, 1)        '统计第一个text里正确的字符数

 sSource(i) = Mid(Label1.Caption, i, 1)

If sInput(i) = sSource(i) Then

iCorrect = iCorrect + 1

End If

Next

 

For i = 1 To 60                           '统计第二个text里正确的字符数

sInput(i) = Mid(Text2.Text, i, 1)

 sSource(i) = Mid(Label2.Caption, i, 1)

 

If sInput(i) = sSource(i) Then

iCorrect = iCorrect + 1

End If

Next

 

For i = 1 To 60                            '统计第三个text里正确的字符数

sInput(i) = Mid(Text3.Text, i, 1)

 sSource(i) = Mid(Label3.Caption, i, 1)

 

If sInput(i) = sSource(i) Then

iCorrect = iCorrect + 1

End If

Next

'取字符串iCorrect / iSecond中前四个字符

Text4.Text = Mid(iCorrect / iSecond, 1, 4)

 

'取字符串iCorrect * 100 / 180中前四个字符

Text6.Text = Mid(iCorrect * 100 / 180, 1, 4) & "%"

 

'db1中添加数据

Data1.Recordset.AddNew

Data1.Recordset.Fields("用户名") = Text5.Text

Data1.Recordset.Fields("速度") = Text4.Text

Data1.Recordset.Fields("正确率") = Text6.Text

Data1.Recordset.Fields("难度") = Text7.Text

Data1.Recordset.Update

 

'记时器清零

iSecond = 0

Text5.Text = ""

End Sub

 

Private Sub MSHFlexGrid1_Click()

End Sub

 

Private Sub Command3_Click()

Form2.Show

End Sub

 

Private Sub Command4_Click()

End

End Sub

 

Private Sub Form_Load()

'运行时Command1Command2不可用

Command1.Enabled = False

 

Command2.Enabled = False

End Sub 1191

[1] [2] [3] 下一页

Copyright © 2007-2012 www.chuibin.com 六维论文网 版权所有