VB猜字小游戏程序问题
的有关信息介绍如下:在声明变量时应该给变量a也指定数据类型,这样比较恰当.如Dim a As Integer, b As Integer否则,a是Variant而不是Integer.在过程外的声明可以删掉(不算错误,只是多余)Text1.Text = a这一句也有问题,应该反过来a = Int(Val(Text1.Text))IF语句也可以简化一下(但这个不算错误)If a = b Then Label3.Caption = "答对了"ElseIf a > b Then Label3.Caption = "太大了"Else Label3.Caption = "太小了"End If修改后的代码如下:Private Sub Command1_Click() Dim a As Integer, b As Integer b = Int(Rnd * 10) a = Int(Val(Text1.Text)) If a = b Then Label3.Caption = "答对了" ElseIf a > b Then Label3.Caption = "太大了" Else Label3.Caption = "太小了" End IfEnd Sub如果还有问题欢迎追问,问题解决请及时选为满意回答,谢谢.