📄 猜数字.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "猜数字"
ClientHeight = 3195
ClientLeft = 3990
ClientTop = 2760
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
Begin VB.CommandButton Command3
Caption = "我不想玩了"
Height = 495
Left = 3120
TabIndex = 5
Top = 2520
Width = 1215
End
Begin VB.TextBox Text1
Height = 495
Left = 600
TabIndex = 4
Text = "Text1"
Top = 720
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "再来一次"
Height = 495
Left = 1680
TabIndex = 1
Top = 2520
Width = 1215
End
Begin VB.Timer Timer1
Interval = 1000
Left = 480
Top = 2520
End
Begin VB.CommandButton Command1
Caption = "确定"
Default = -1 'True
Height = 495
Left = 600
TabIndex = 0
Top = 120
Width = 1215
End
Begin VB.Label Label2
BorderStyle = 1 'Fixed Single
Caption = "Label2"
Height = 855
Left = 360
TabIndex = 3
Top = 1440
Width = 3855
End
Begin VB.Label Label1
BorderStyle = 1 'Fixed Single
Caption = "Label1"
Height = 1095
Left = 2520
TabIndex = 2
Top = 120
Width = 1455
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim number As Long
Private Sub Command1_Click()
If Text1.Text = "" Then
MsgBox "笨蛋,你连数都没输入,猜你个头啊!"
Else
If Text1.Text > number Then
Label2.Caption = "大了!"
End If
If Text1.Text < number Then
Label2.Caption = "小了!"
End If
If Text1.Text = number Then
Label2.Caption = "恭喜你,你猜对了!"
Timer1.Enabled = False
Command1.Enabled = False
Command2.Enabled = True
End If
Text1.Text = ""
End If
End Sub
Private Sub Command2_Click()
Form_Load
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Form_Load()
Randomize
number = Int(Rnd * 99) + 1
Command2.Enabled = False
Command1.Enabled = True
Label1.Caption = 20
Label2.Caption = ""
Text1.Text = ""
MsgBox "准备好,游戏马上开始"
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Label1.Caption - 1
If Label1.Caption = 0 Then
Label2.Caption = "时间到,你要猜的数字是:" & number
Command1.Enabled = False
Command2.Enabled = True
Timer1.Enabled = False
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -