simple userform code

simple userform code

Anonymous
Not applicable
292 Views
5 Replies
Message 1 of 6

simple userform code

Anonymous
Not applicable
I have asimple userform which consists of 2 option buttons (1 and 2) and one combo box (with choice of a b c and d). What i want to do is have user select one or the other option buttons (1 or 2) and the combobox display a and b if option button 1 selected or c and d if option button 2 selected.
Then user selects a or b or c or d and the result to be saved as an attribute for a block insertion. Can anyone supply mewith some code to do this
0 Likes
293 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
In the click event handler for each option button, clear the contents of the combobox and refill it with the appropriate values. -- There are 10 kinds of people: those who understand binary and those who don't.
0 Likes
Message 3 of 6

Anonymous
Not applicable
how do i do that. i am just a new programmer
0 Likes
Message 4 of 6

Anonymous
Not applicable
this is what i have at present


Private Sub OptionButton1_Click()
If OptionButton1 = True Then
Cbofirstend.AddItem "a"
Cbofirstend.AddItem "b"
Cbofirstend.ListIndex = 1
End If
If OptionButton2 = True Then
'clear combobox'

Cbofirstend.AddItem "c"
Cbofirstend.AddItem "d"
Cbofirstend.ListIndex = 1
End If
End Sub
0 Likes
Message 5 of 6

Anonymous
Not applicable
johnbortoli wrote: > this is what i have at present > > > Private Sub OptionButton1_Click() > If OptionButton1 = True Then > Cbofirstend.AddItem "a" > Cbofirstend.AddItem "b" > Cbofirstend.ListIndex = 1 > End If > If OptionButton2 = True Then > 'clear combobox' > > Cbofirstend.AddItem "c" > Cbofirstend.AddItem "d" > Cbofirstend.ListIndex = 1 > End If > End Sub Almost there. Separate the two blocks of code; the top section in OptionButton1_Click, the bootm section in OptionButton2_Click. Next, be sure to clear the Combobox before you start adding items to it. -- There are 10 kinds of people: those who understand binary and those who don't.
0 Likes
Message 6 of 6

Anonymous
Not applicable
Private Sub OptionButton1_Click() With ComboBox1 .Clear .AddItem "A" .AddItem "B" .ListIndex = 0 End With End Sub Private Sub OptionButton2_Click() With ComboBox1 .Clear .AddItem "C" .AddItem "D" .ListIndex = 0 End With End Sub No need for any "if then" construct "johnbortoli" wrote in message news:22762525.1107500732407.JavaMail.jive@jiveforum1.autodesk.com... > this is what i have at present > > > Private Sub OptionButton1_Click() > If OptionButton1 = True Then > Cbofirstend.AddItem "a" > Cbofirstend.AddItem "b" > Cbofirstend.ListIndex = 1 > End If > If OptionButton2 = True Then > 'clear combobox' > > Cbofirstend.AddItem "c" > Cbofirstend.AddItem "d" > Cbofirstend.ListIndex = 1 > End If > End Sub
0 Likes