以下代码仅在选择option1时有效,我想知道我的错误和背后的逻辑 因此走了;
Dim Question(2) as string
Dim i as long
Private Sub Form1_Load()
Question(0)= "q1 here"
Question(1)="q2 here"
Question(2)="q3 here"
For i = 0 to 2
if option1(i).Value=True Then
Label1.Caption=Option1(i).Caption
Else: Label1.caption= MsgBox "Please Select an Option"
End IF
Next i
End Sub
答案 0 :(得分:0)
很难从上面的代码中分辨出你在做什么。但是,如果您想要做的只是在单击OptionButton时在标签中显示问题,请尝试以下操作。如果这没有回答您的问题,请澄清。
Private Sub Form1_Load()
Question(0).Caption = "q1 here"
Question(1).Caption = "q2 here"
Question(2).Caption = "q3 here"
End Sub
Private Sub Question_Click(Index As Integer)
Dim i As Long
For i = 0 To 2
If Question(i).Value = True Then
Label1.Caption = Question(i).Caption
Exit For
Else
Label1.Caption = "Please Select an Option"
End If
Next i
End Sub