📄 frmfallingletters.frm
字号:
VERSION 5.00
Begin VB.Form frmfallingletters
BorderStyle = 3 'Fixed Dialog
Caption = "Falling Letters"
ClientHeight = 3630
ClientLeft = 45
ClientTop = 330
ClientWidth = 3690
LinkTopic = "Form2"
MaxButton = 0 'False
MinButton = 0 'False
Moveable = 0 'False
ScaleHeight = 3630
ScaleWidth = 3690
ShowInTaskbar = 0 'False
StartUpPosition = 2 'CenterScreen
Begin VB.PictureBox Picture1
BackColor = &H8000000D&
Height = 3285
Left = 0
ScaleHeight = 3225
ScaleWidth = 3375
TabIndex = 0
Top = 0
Width = 3435
Begin VB.Label ch1
AutoSize = -1 'True
BackColor = &H8000000D&
Caption = "Press Any Key To Start"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H8000000E&
Height = 240
Left = 150
TabIndex = 2
Top = 120
Width = 2400
End
End
Begin VB.Timer Timer1
Left = 840
Top = 3480
End
Begin VB.CommandButton Command1
Caption = "Exit"
Height = 255
Left = 3120
TabIndex = 1
Top = 3360
Width = 495
End
Begin VB.Label Label4
AutoSize = -1 'True
BackColor = &H80000012&
Caption = "5"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H8000000E&
Height = 240
Left = 3480
TabIndex = 6
Top = 2520
Width = 135
End
Begin VB.Label Label3
AutoSize = -1 'True
BackColor = &H80000012&
Caption = "10"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 240
Left = 3480
TabIndex = 5
Top = 1680
Width = 255
End
Begin VB.Label Label2
AutoSize = -1 'True
BackColor = &H80000012&
Caption = "15"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H8000000E&
Height = 240
Left = 3480
TabIndex = 4
Top = 840
Width = 255
End
Begin VB.Label Label1
AutoSize = -1 'True
BackColor = &H80000012&
Caption = "20"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H8000000E&
Height = 240
Left = 3480
TabIndex = 3
Top = 120
Width = 255
End
End
Attribute VB_Name = "frmfallingletters"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim count1 As Integer, count2 As Integer, marks As Integer
Dim hits As Integer, i As Integer
Dim key_typed As String
Dim starting As Boolean
Dim char_count As Integer
Dim level_count(10) As Integer
Dim temp As String
Dim atempts As Integer
Function getchar() As String
Dim i As Integer
i = Int(25 * Rnd + 97)
getchar = Chr(i)
End Function
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
Picture1_KeyPress (KeyAscii)
End Sub
Private Sub Form_Load()
atempts = 0
char_count = 0
ch1.Caption = "Press any Key to Start"
ch1.Left = 100
i = 0
While (i < 10)
level_count(i) = 0
i = i + 1
Wend
starting = False
Timer1.Enabled = False
Timer1.Interval = 100
ch1.Visible = True
End Sub
Private Sub Picture1_KeyPress(KeyAscii As Integer)
If (KeyAscii = 27) Then
Timer1.Enabled = False
Unload Me
End If
If (starting = False) Then
starting = True
Timer1.Enabled = True
Else
key_typed = Chr(KeyAscii)
End If
End Sub
Private Sub Timer1_Timer()
If (char_count <= 50) Then
If (key_typed <> ch1.Caption) Then
ch1.Top = ch1.Top + 190
Else
atempts = atempts + 1
hits = hits + 1
If (ch1.Top <= Picture1.Top + Picture1.Height / 10) Then
level_count(9) = level_count(9) + 1
ElseIf (ch1.Top <= Picture1.Top + 2 * Picture1.Height / 10) Then
level_count(8) = level_count(8) + 1
ElseIf (ch1.Top <= Picture1.Top + 3 * Picture1.Height / 10) Then
level_count(7) = level_count(7) + 1
ElseIf (ch1.Top <= Picture1.Top + 4 * Picture1.Height / 10) Then
level_count(6) = level_count(6) + 1
ElseIf (ch1.Top <= Picture1.Top + 5 * Picture1.Height / 10) Then
level_count(5) = level_count(5) + 1
ElseIf (ch1.Top <= Picture1.Top + 6 * Picture1.Height / 10) Then
level_count(4) = level_count(4) + 1
ElseIf (ch1.Top <= Picture1.Top + 7 * Picture1.Height / 10) Then
level_count(3) = level_count(3) + 1
ElseIf (ch1.Top <= Picture1.Top + 8 * Picture1.Height / 10) Then
level_count(2) = level_count(2) + 1
ElseIf (ch1.Top <= Picture1.Top + 9 * Picture1.Height / 10) Then
level_count(1) = level_count(1) + 1
ElseIf (ch1.Top <= Picture1.Top + Picture1.Height) Then
level_count(0) = level_count(0) + 1
End If
char_count = char_count + 1
ch1.Caption = getchar
Picture1.Cls
ch1.Top = Picture1.Top
End If
Else
Timer1.Enabled = False
ch1.Visible = False
temp = ""
marks = 0
For i = 9 To 0 Step -1
temp = temp + "Hits at Row " + str(i * 2 + 2) + " -> " + str(level_count(i)) + vbNewLine
marks = marks + level_count(i) * (i * 2 + 2)
Next
temp = temp + "Atempts -> " + str(atempts) + "/50" + vbNewLine
temp = temp + "Total score -> " + str(marks) + "/1000" + vbNewLine
MsgBox temp
Call Form_Load
End If
If (ch1.Top > (Picture1.Top + Picture1.Height - ch1.Height)) Then
char_count = char_count + 1
Picture1.Cls
ch1.Caption = getchar
ch1.Top = Picture1.Top
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -