一个VB的code问题

来源:百度知道 编辑:UC知道 时间:2024/06/05 01:38:41
Private Sub Command1_Click()
If x = True Then
Label1.Caption = "a"
End If
If y = True Then
Label1.Caption = "b"
End If
End Sub

Private Sub Command2_Click()
x = False
y = False
End Sub

Private Sub Form_Load()
Text1.Text = " "
End Sub

Private Sub Option1_Click()
Dim x As Boolean

Dim y As Boolean
y = False

x = True
End Sub

Private Sub Option2_Click()
Dim x As Boolean
x = False
Dim y As Boolean
y = True
End Sub

我想当我按了radio button1后,再按command1,就会出现a
当我按了radio button2后,再按command1,就会出现b
command2是用来把x,y变会true 的。。

这段code不是我最后想要的,我只是把很多东西,缩小了。。
我只是想知道,这样子是哪里错了?
就对于这个,修改下,不要给重写了
谢谢

x和y要设置成全局变量
Dim x As Boolean ,y As Boolean
要写在代码的最顶端,而且只要写一次
在其它的地方就不要再重复dim了
在Click()如果dim了那么就只作用在过程里,过程一结束在过程dim的变量会全部失效