主题:再次请教单选按钮互斥问题
刚才在电脑上又做了一题,以控件数组形式编写程序:窗体中有一组单选按钮和一个文本框,单选按钮包括普通、粗体、斜体和粗斜体4种字形。文本框中的文字将按所选择的选项进行设置。我写的代码为:
Private Sub Form_Load()
Text1.Text = "框架和按钮"
Frame1.Caption = "字形"
Option1(0).Caption = "普通"
Option1(1).Caption = "粗体"
Option1(2).Caption = "斜体"
Option1(3).Caption = "粗斜体"
End Sub
Private Sub Option1_Click(Index As Integer)
If Index = 0 Then
Text1.FontBold = False
Text1.FontItalic = False
End If
If Index = 1 Then Text1.FontBold = True
If Index = 2 Then Text1.FontItalic = True
If Index = 3 Then
Text1.FontBold = True
Text1.FontItalic = True
End If
End Sub
问题1:大家请注意观察我上传的运行界面:居然可以同时选择两个单选按钮耶~~~
问题2:运行后,如果选中“斜体”则文字变成斜体效果,接着选中“粗体”文字本应该只变成粗体效果,但在机器上变成了即是斜体又是粗体。必须重新在代码中加else语句才行。可是同样的代码在其他的机器上都可以运行成功呀!
谁能告诉我,这是为什么?!
[em52][em6]
Private Sub Form_Load()
Text1.Text = "框架和按钮"
Frame1.Caption = "字形"
Option1(0).Caption = "普通"
Option1(1).Caption = "粗体"
Option1(2).Caption = "斜体"
Option1(3).Caption = "粗斜体"
End Sub
Private Sub Option1_Click(Index As Integer)
If Index = 0 Then
Text1.FontBold = False
Text1.FontItalic = False
End If
If Index = 1 Then Text1.FontBold = True
If Index = 2 Then Text1.FontItalic = True
If Index = 3 Then
Text1.FontBold = True
Text1.FontItalic = True
End If
End Sub
问题1:大家请注意观察我上传的运行界面:居然可以同时选择两个单选按钮耶~~~
问题2:运行后,如果选中“斜体”则文字变成斜体效果,接着选中“粗体”文字本应该只变成粗体效果,但在机器上变成了即是斜体又是粗体。必须重新在代码中加else语句才行。可是同样的代码在其他的机器上都可以运行成功呀!
谁能告诉我,这是为什么?!
[em52][em6]