2个回答
展开全部
Randomize
Dim a As Integer
Dim b As Integer
a = Int(Rnd * 100)
s1 = "请输入"
For i = 1 To 10
b = InputBox(s1, "猜一猜")
If b > a Then
s1 = "请输入(大了)"
ElseIf b < a Then
s1 = "请输入(小了)"
Else
MsgBox "恭喜在第" & i & "次猜中了", vbInformation, "猜一猜"
Exit For
End If
Next i
If i > 10 Then
'猜题结束
MsgBox "你真衰,(答案是" & a & ")" & vbCrLf & "猜题结束", vbInformation, "猜一猜"
End If
Dim a As Integer
Dim b As Integer
a = Int(Rnd * 100)
s1 = "请输入"
For i = 1 To 10
b = InputBox(s1, "猜一猜")
If b > a Then
s1 = "请输入(大了)"
ElseIf b < a Then
s1 = "请输入(小了)"
Else
MsgBox "恭喜在第" & i & "次猜中了", vbInformation, "猜一猜"
Exit For
End If
Next i
If i > 10 Then
'猜题结束
MsgBox "你真衰,(答案是" & a & ")" & vbCrLf & "猜题结束", vbInformation, "猜一猜"
End If
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询