建议使用 列表框 listbox ,这样看起来更清晰
代码也做了一些调整,你看看吧:
Dim c As Long
Private Sub Command1_Click()
c = Int(100 * Rnd + 1)
End Sub
Private Sub CommandOK_Click()
Dim b As Long
b = Val(InputBox("请输入一个数字(1-100)", "猜数字"))
Select Case b
Case Is > 100 Or b < 1:
MsgBox "请输入正确的值!"
Exit Sub
Case c:
txt.Text = b & " 恭喜你猜对了!"
MsgBox txt.Text, 0, "恭喜"
Case Is > c:
txt.Text = b & " 太大了!"
MsgBox txt.Text, 0, "错误"
CommandOK.SetFocus
Case Is < c:
txt.Text = b & " 太小了!"
MsgBox txt.Text, 0, "错误"
CommandOK.SetFocus
End Select
List1.AddItem txt.Text
End Sub
Private Sub CommandOUT_Click()
End
End Sub
Private Sub Form_Load()
c = Int(100 * Rnd + 1)
End Sub