Cara
Cara

Reputation: 3

How to code using radio buttons in VB.net for Windows?

So I am having difficulty coding with radio buttons. I have 4 radio buttons in 2 different lists.

Status     
 - Member  
 - Non Member

Age  
 - Over 65  
 - Under 65  

Fee Box        Display Button


If
  Member and Over 65 = $5 
ElseIf 
  Non Member and Under 65 = $50
ElseIf 
  Member and Under 65 = $5
ElseIf
  Non Member and Over 65 = 50$

Sorry if that was confusing, any help works thankyoU!

Edit:

Hey guys! My teacher ended up helping me thankyou though!

Upvotes: 0

Views: 2895

Answers (1)

Brian
Brian

Reputation: 38035

Assuming you are using WinForms and the WinForm designer to put radio buttons on the form, you should be able to handle the change event for the radio buttons. You can use the same change event for all the radio buttons and just setup your calculation there (there are better ways of doing it, but this is a very simple way to do it).

From memory (I haven't done VB.Net in a couple years)...

Public Sub Radio_Changed(sender As Object, e As EventArgs) Handles Radio1.Changed, Radio2.Changed, Radio3.Changed, Radio4.Changed
    If Member Then
        Cost = 5
    Else
        Cost = 50
    End If
End Sub

Upvotes: 1

Related Questions