初学vb 想请教高手关于单选按钮option应用的问题.

来源:百度知道 编辑:UC知道 时间:2024/05/15 10:02:17
希望实现以下功能:在单击各个单选按钮的时候,在文本框中显示:"您选择的是A处理器和B操作系统",其中A用处理器框架中的选项代替,B用操作系统框架中的选项代替。

处理器
单选框内容
pentium
pentium3
pentium4
操作系统单选框的内容
Windows Me
Windows 2000
Windows XP

不明白如何在文本框中同时显示两组单选框中选择的内容。谢谢指点~~
Private Sub optPentium4_Click()
If optWindowsMe.Value = True Then
TxtDisplay.Text = "您选择的是Pentium4处理器和Windows Me操作系统"
ElseIf optWindows2000.Value = True Then
TxtDisplay.Text = "您选择的是Pentium4处理器和Windows 2000操作系统"
ElseIf optWindowsXP.Value = True Then
TxtDisplay.Text = "您选择的是Pentium4处理器和Windows XP操作系统"
End If
End Sub

Private Sub optWindows2000_Click()
If optPentium.Value = True Then
TxtDisplay.Text = "您选择的是Pentium处理器和Windows 2000操作系统"
ElseIf optPentium3.Value = True Then
TxtDisplay.Text = "您选择的是Pentium3处理器和Windows 2000操作系统"
ElseIf optPentium4.Value = True Then
TxtDisplay.Text = "您选择的是Pen

将两组单选按钮分别放到两个frame中。
之后代码如下:
Private Sub Form_Load()
selectPen ("Pentium4")
End Sub

Private Sub optPentium_Click()
selectPen ("Pentium")
End Sub

Private Sub optPentium3_Click()
selectPen ("Pentium3")
End Sub

Private Sub optPentium4_Click()
selectPen ("Pentium4")
End Sub

Private Sub optWindows2000_Click()
selectWin ("Windows 2000")
End Sub

Public Function selectPen(pen)
If optWindowsMe.Value = True Then
TxtDisplay.Text = "您选择的是" + pen + "处理器和Windows Me操作系统"
ElseIf optWindows2000.Value = True Then
TxtDisplay.Text = "您选择的是" + pen + "处理器和Windows 2000操作系统"
ElseIf optWindowsXP.Value = True Then
TxtDisplay.Text = "您选择的是" + pen + "处理器和Windows XP操作系统"
End If
End Function

Public Function selectWin(win)
If optPentium.