我想编写一个猜数字的游戏,可是

来源:百度知道 编辑:UC知道 时间:2024/09/24 05:26:27
Private Sub cmdsure_Click()
a = 0
b = 0
’判断几个位置对存于a,几个数字对位置不对,存于b
If i1.Text = r1.Text Then
a = a + 1
End If
If i2.Text = r2.Text Then
a = a + 1
End If
If i3.Text = r3.Text Then
a = a + 1
End If
If i4.Text = r4.Text Then
a = a + 1
End If
If (i1.Text = r2.Text Or i1.Text = r3.Text Or i1.Text = r4.Text) Then
b = b + 1
End If
If (i2.Text = r1.Text Or i2.Text = r3.Text Or i2.Text = r4.Text) Then
b = b + 1
End If
If (i3.Text = r1.Text Or i3.Text = r2.Text Or i3.Text = r4.Text) Then
b = b + 1
End If
If (i4.Text = r1.Text Or i4.Text = r2.Text Or i4.Text = r3.Text) Then
b = b + 1
End If
If a = 4 Then
Form1.Hide
Form2.Show
End If
If (c = 9 And a < 4) Then
Form1.Hide
Form3.Show
End If
Select Case c
‘每次猜完结果存于textN,分析结果位置对a和数字对但位置不对b存于t1和t11,并使之不可更改
Case 1
Text1.Text = i1.Text + i2.Text + i3.Text

我试过你的代码,虽然有些小瑕疵,但主要过程都没问题啊。你说那文本框无变化,你看一下那些文本框Enable属性的默认初始属性是否是Ture?如果一开始就是False就不可能有得变的。还有,建议把c=c+1这一句放到代码开始的b=0后面;确保 Dim c As Integer 放到代码框通用区域;Case 7 里面的 Text.Enabled = False 改为 Text7.Enabled = False 。