dim sj as Integer ,i as Integer
1)运行程序,单击“开始“按钮,程序就产生一个0到100之间的随机数整数。
Randomize
sj = Int(Rnd * 101)
(2)用户在文本框中输入一个猜想的整数,单击“猜!“按钮,当输入数值正确,则在标签控件中显示“你猜对了!,共猜了n次”,否则,提示“你猜小了(或大了),再试一次吧!”,重新输入整数,反复执行第2步,直到程序显示“你猜对了!”。
i = i + 1
a = Int(Text1.Text)
If a > sj Then MsgBox "你猜大了" ElseIf a < sj Then MsgBox "你猜小了" Else MsgBox "猜对了,共猜了" & i & "次"
End If
Private Sub Command1_Click()
Dim c, b, d As Integer
For b = 1 To 10 c = InputBox("输入数字", "输入数字", 50) If c < a Then MsgBox "小了" ElseIf c > a Then MsgBox "大了" Else MsgBox "对了" Exit For End If
Next
If b = 11 Then MsgBox "你输了" Else MsgBox "你赢了" End If