ControlButtons in a UserForm

S

salut

I have the following code to get values from OptionButtons. The problem is,
seems that the code "TypeOf ctl is OptioinButton" always has value "False"
even when ctl is an OptionButton. Could anybody tell me what did I do wrong
in the code? Thanks a lot!
----------------------------------------------------------------------------
for each ctrl in form1
If TypeOf ctl Is OptionButton Then
If ctl.Value = -1 Then
Total = Total + CInt(ctl.Tag)
End If
testnumber = 1
Else
End If
next
------------------------------------------------------------------------------------
 
D

Dave Peterson

Sometimes you use ctrl. Sometimes you use ctl.

And whatever you use, try this:
If TypeOf Ctrl Is msforms.OptionButton Then
 
T

Tom Ogilvy

for each ctrl in form1
If TypeOf ctl Is MSForms.OptionButton Then
If ctl.Value = -1 Then
Total = Total + CInt(ctl.Tag)
End If
testnumber = 1
Else
End If
next

--
Regards,
Tom Ogilvy


salut said:
I have the following code to get values from OptionButtons. The problem is,
seems that the code "TypeOf ctl is OptioinButton" always has value "False"
even when ctl is an OptionButton. Could anybody tell me what did I do wrong
in the code? Thanks a lot!
-------------------------------------------------------------------------- --
for each ctrl in form1
If TypeOf ctl Is OptionButton Then
If ctl.Value = -1 Then
Total = Total + CInt(ctl.Tag)
End If
testnumber = 1
Else
End If
next
--------------------------------------------------------------------------
----------
 
S

salut

That works. Thanks a lot!

Dave Peterson said:
Sometimes you use ctrl. Sometimes you use ctl.

And whatever you use, try this:
If TypeOf Ctrl Is msforms.OptionButton Then
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top