📄 猜数游戏.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "猜数游戏"
ClientHeight = 4950
ClientLeft = 60
ClientTop = 450
ClientWidth = 4125
LinkTopic = "Form1"
ScaleHeight = 4950
ScaleWidth = 4125
StartUpPosition = 3 '窗口缺省
Begin VB.ListBox List3
Height = 2400
Left = 1200
TabIndex = 8
Top = 1800
Width = 375
End
Begin VB.ListBox List2
Height = 2400
Left = 720
TabIndex = 7
Top = 1800
Width = 375
End
Begin VB.ListBox List1
Height = 2400
Left = 240
TabIndex = 6
Top = 1800
Width = 375
End
Begin VB.CommandButton Command2
Caption = "确定"
Height = 375
Left = 3000
TabIndex = 4
Top = 840
Width = 855
End
Begin VB.TextBox Text1
Alignment = 1 'Right Justify
Height = 375
Left = 2040
TabIndex = 3
Top = 840
Width = 855
End
Begin VB.CommandButton Command3
Caption = "答案"
Height = 375
Left = 3000
TabIndex = 1
Top = 240
Width = 855
End
Begin VB.CommandButton Command1
Caption = "出题"
Height = 375
Left = 240
TabIndex = 0
Top = 240
Width = 975
End
Begin VB.Label Label3
Height = 2415
Left = 1920
TabIndex = 9
Top = 1800
Width = 1695
End
Begin VB.Label Label2
Caption = "次数 数字 结果"
Height = 255
Left = 240
TabIndex = 5
Top = 1440
Width = 1455
End
Begin VB.Label Label1
Caption = "请输入要猜的数字"
Height = 255
Left = 360
TabIndex = 2
Top = 840
Width = 1575
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim x, y As Integer
Dim i As Integer
Private Sub Command1_Click()
Randomize
x = Int(Rnd * 9 + 0)
List1.Clear
List2.Clear
List3.Clear
i = 0
Text1.SetFocus
End Sub
Private Sub Command2_Click()
a = Val(Text1.Text)
i = 1 + i
List1.AddItem i
List2.AddItem a
If x > a Then
List3.AddItem ("小")
Label3 = "您所猜的数字小了点,请重新猜!"
ElseIf x < a Then
List3.AddItem ("大")
Label3 = "您所猜的数字大了点,请重新猜!"
Else
Label3 = "您真聪明。您所猜的数字正确,请重新出题!"
End If
Text1 = ""
Text1.SetFocus
End Sub
Private Sub Command3_Click()
MsgBox (x)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -