各位大大,以下是我做的打字游戏代码, 求改进
1 不用三个独立的label,而用控件数组控制字母下落
2 我想查询成绩时若无该名字记录显示无记录,可我对EOF掌握太差,望各位大大帮忙改进添加一下代码
3 我想设立英雄榜,但我不会用数据库,望各位大大告诉我详细过程与代码,谢谢各位大大
4 我想在开始菜单下加一停止,使一切数据回归初始状态,可总是溢出,望各位大大也给个详细代码
谢谢各位大大,以下是我全部代码:
Dim a As Integer
Sub Cer()
Label3.Caption = Chr(Round(Rnd * 28) + 62)
Label3.Left = Int(Rnd * F2.Width)
Label3.Top = F2.Top
End Sub
Sub Cer1()
Label4.Caption = Chr(Round(Rnd * 28) + 94)
Label4.Left = Int(Rnd * F2.Width)
Label4.Top = F2.Top
End Sub
Sub Cer2()
Label5.Caption = Chr(Round(Rnd * 10) + 47)
Label5.Left = Int(Rnd * F2.Width)
Label5.Top = F2.Top
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) = Label3.Caption Then
Text1.Text = Val(Text1.Text) + 1
Text3.Text = Val(Text3.Text) + 1
Cer
End If
If Chr(KeyAscii) = Label4.Caption Then
Text1.Text = Val(Text1.Text) + 1
Text3.Text = Val(Text3.Text) + 1
Cer1
End If
If Chr(KeyAscii) = Label5.Caption Then
Text1.Text = Val(Text1.Text) + 1
Text3.Text = Val(Text3.Text) + 1
Cer2
End If
If Text3.Text > 0 Then
Timer3.Enabled = True
End If
End SubPrivate Sub Form_Load()
Dim Name As String
Name = InputBox("请输入你的大名", , "匿名")
Form1.Caption = "打字练习" & "--" & Name
F2.BorderStyle = 0
Label3.Visible = False
Label4.Visible = False
Label5.Visible = False
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
VBexit.Enabled = False
Timer3.Interval = 100
End Sub
Private Sub Timer3_Timer()
Text4.Text = Val(Text1.Text) / Val(Text3.Text)
Text4.Text = Format(Text4.Text, "0.0%")
End SubPrivate Sub VBbanben_Click()
MsgBox "版本所有人----王鑫淼" & vbCrLf & "版本 : 1.0" & vbCrLf & "制作日期  2009.6.18", , "帮助"
End SubPrivate Sub VBcolor_Click()
CommonDialog2.Flags = vbCCRGBInit
CommonDialog2.Color = BackColor
CommonDialog2.Action = 3
F2.BackColor = CommonDialog2.Color
Label3.BackColor = CommonDialog2.Color
Label4.BackColor = CommonDialog2.Color
Label5.BackColor = CommonDialog2.Color
End Sub
Private Sub VBletter_Click()
CommonDialog1.Flags = 3
CommonDialog1.ShowFont
Label3.FontName = CommonDialog1.FontName
Label3.FontSize = CommonDialog1.FontSize
Label3.FontBold = CommonDialog1.FontBold
Label3.FontItalic = CommonDialog1.FontItalic
Label3.FontUnderline = CommonDialog1.FontUnderline
Label4.FontName = CommonDialog1.FontName
Label4.FontSize = CommonDialog1.FontSize
Label4.FontBold = CommonDialog1.FontBold
Label4.FontItalic = CommonDialog1.FontItalic
Label4.FontUnderline = CommonDialog1.FontUnderline
Label5.FontName = CommonDialog1.FontName
Label5.FontSize = CommonDialog1.FontSize
Label5.FontBold = CommonDialog1.FontBold
Label5.FontItalic = CommonDialog1.FontItalic
Label5.FontUnderline = CommonDialog1.FontUnderline
End Sub
Private Sub VBlist_Click()
F2.Visible = False
End Sub
Private Sub VBjunior_Click()
Open "out.txt" For Input As #1
Input #1, score
Close #1
Cls
Print score
End Sub
Private Sub VBmiddle_Click()
Open "out1.txt" For Input As #1
Input #1, score1
Close #1
Cls
Print score1
End Sub
Private Sub VBsenior_Click()
Open "out2.txt" For Input As #1
Input #1, score2
Close #1
Cls
Print score2
End Sub
Private Sub VBstart_Click()
Cer
Cer1
Cer2
VBlist.Enabled = False
F2.Visible = True
Timer1.Enabled = True
Timer2.Enabled = True
VBexit.Enabled = True
VBstop.Enabled = True
VBstart.Enabled = False
Frame1.Enabled = False
VBtime.Enabled = False
End Sub
Private Sub VBstop_Click()
VBlist.Enabled = True
Timer1.Enabled = False
Timer2.Enabled = False
VBstart.Enabled = True
VBstop.Enabled = False
End Sub
Private Sub VBexit_Click()
Msg1 = "你的正确率为": Msg2 = Text4.Text
Msg3 = "由于你没完成不能记成绩"
MsgBox Msg1 & Msg2 & Msg3
End
End Sub
Private Sub VBtime_Click()
Again:
a = InputBox("请输入游戏时间")
If a < 10 Or Not IsNumeric(a) Then
   MsgBox "请重新输入10秒以上"
 GoTo Again
End If
Text2.Text = a
End Sub
Private Sub Timer2_Timer()
If Val(Text2.Text) > 0 Then
Text2.Text = Val(Text2.Text) - 1
End If
End Sub
Private Sub Timer1_Timer()
If Op1.Value Then
   Label3.Visible = True
   Timer1.Interval = 200
   If Val(Text2.Text) > 0 Then
   Label3.Top = Label3.Top + 100
        If Label3.Top > F2.Height Then
          Text3.Text = Val(Text3.Text) + 1
           Cer
         End If
   Else
        Msg4 = "你的正确率为": Msg5 = Text4.Text
        MsgBox Msg4 & Msg5
        Msg1 = "你继续吗?"
        Result = MsgBox(Msg1, vbOKCancel)
        If Result = 1 Then
Again:
        a = InputBox("请输入游戏时间")
             If a < 0 Or Not IsNumeric(a) Then
               MsgBox "请重新输入"
GoTo Again
             End If
             Text2.Text = a
        ElseIf Result = 2 Then
        Open "out.txt" For Output As #1
        Print #1, Form1.Caption, "正确率" & Val(Text4.Text) & "%" & "--" & Op1.Caption & "--" & a & "秒"
        Close #1
        End
        End If
    End If
End If
If Op2.Value Then
   Label3.Visible = True
   Label4.Visible = True
   Timer1.Interval = 100
   If Val(Text2.Text) > 0 Then
   Label3.Top = Label3.Top + 100
        If Label3.Top > F2.Height Then
          Text3.Text = Val(Text3.Text) + 1
           Cer
         End If
   Label4.Top = Label4.Top + 100
        If Label4.Top > F2.Height Then
          Text3.Text = Val(Text3.Text) + 1
           Cer1
         End If
   Else
        Msg4 = "你的正确率为": Msg5 = Text4.Text
        MsgBox Msg4 & Msg5
        Msg1 = "你继续吗?"
        Result = MsgBox(Msg1, vbOKCancel)
        If Result = 1 Then
Again1:
        a = InputBox("请输入游戏时间")
             If a < 0 Or Not IsNumeric(a) Then
               MsgBox "请重新输入"
GoTo Again1
             End If
             Text2.Text = a
        ElseIf Result = 2 Then
        Open "out1.txt" For Output As #1
        Print #1, Form1.Caption, "正确率" & Val(Text4.Text) & "%" & "--" & Op2.Caption & "--" & a & "秒"
        End
        End If
    End If
End If
If Op3.Value Then
   Label3.Visible = True
   Label4.Visible = True
   Label5.Visible = True
   Timer1.Interval = 50
   If Val(Text2.Text) > 0 Then
   Label3.Top = Label3.Top + 100
        If Label3.Top > F2.Height Then
          Text3.Text = Val(Text3.Text) + 1
           Cer
         End If
   Label4.Top = Label4.Top + 100
        If Label4.Top > F2.Height Then
          Text3.Text = Val(Text3.Text) + 1
           Cer1
         End If
   Label5.Top = Label5.Top + 100
        If Label5.Top > F2.Height Then
          Text3.Text = Val(Text3.Text) + 1
           Cer2
         End If
   Else
        Msg4 = "你的正确率为": Msg5 = Text4.Text
        MsgBox Msg4 & Msg5
        Msg1 = "你继续吗?"
        Result = MsgBox(Msg1, vbOKCancel)
        If Result = 1 Then
Again2:
        a = InputBox("请输入游戏时间")
             If a < 0 Or Not IsNumeric(a) Then
               MsgBox "请重新输入"
GoTo Again2
             End If
             Text2.Text = a
        ElseIf Result = 2 Then
        Open "out2.txt" For Output As #1
        Print #1, Form1.Caption, "正确率" & Val(Text4.Text) & "%" & "--" & Op3.Caption & "--" & a & "秒"
        End
        End If
    End If
End If
End SubPrivate Sub VByouxi_Click()
MsgBox "这么简单,要嘛帮助?那不是小菜嘛!"
End Sub