Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

For the advanced crowd, this is most likely the simplest and perhaps the supidest thing you've seen posted here, but for newbies, this could save alot of coding time...

 

Say you have a form that has multiple radio buttons in the same list, groupbox or form and you want to trigger different events for each radio button that is checked at the time you program final input checking, a simple select statement can help you with this.

 

So, let's say you have three radio buttons and want to find out which is checked:

 

radYES

radNO

RadCANCEL

 

 [size=2][color=#0000ff]
Select [/color][/size][size=2][color=#0000ff]Case [/color][/size][size=2][color=#0000ff]True




[indent][/color][/size][size=2][color=#0000ff]Case [/color][/size][size=2][color=#0000ff]Is[/color][/size][size=2] = [/size][size=2][color=#0000ff]Me[/color][/size][size=2].radYES.Checked



[/size][size=2][color=#008000]'YES selected

[/color][/size][size=2][color=#0000ff]Case [/color][/size][size=2][color=#0000ff]Is[/color][/size][size=2] = [/size][size=2][color=#0000ff]Me[/color][/size][size=2].radNO.Checked

[/size][size=2][color=#008000]'NO Selected

[/color][/size][size=2][color=#0000ff]Case [/color][/size][size=2][color=#0000ff]Is[/color][/size][size=2] = [/size][size=2][color=#0000ff]Me[/color][/size][size=2].radCANCEL.Checked

[/size][size=2][color=#008000]'CANCEL Selected


[/indent]
[/color][/size][size=2][color=#0000ff]End [/color][/size][size=2][color=#0000ff]Select



[/color][/size]



 

Personnally, I use this when I run final checks on the form inputs before sending the info to the database. It permits me to modify data based on which option is checked by the user.

 

Hope this can help a few.

Laredo512

* using VS.NET Pro 2003 *

  • Leaders
Posted

Well, first of all, the Is = part is unnecessary, because Me.radYes.Checked is a boolean anyway.

 

And besides, what would be the advantage over just using an If Else block?

If Me.radYESChecked Then

ElseIf Me.radNOChecked Then

ElseIf Me.radCANCEL.Checked Then

End If

it would be less typing and more intuitive.

:)

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...