Shoutbox

VB.NET radio buttons help - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: VB.NET radio buttons help (/showthread.php?tid=52633)

VB.NET radio buttons help by Ezra on 11-04-2005 at 08:06 PM

I'm trying to make a little program with 2 groups of radio buttons.

With HTML I would give the 2 groups the same name and a different variable, but how does it work in VB.NET?

I checked the MSDN but couldn't find anything.

What I want is 3 radio buttons to choose a size, and 2 to choose black & white or color.

TIA


RE: VB.NET radio buttons help by Kryptonate on 11-04-2005 at 08:42 PM

You can work with 2 seperate functions. The first one includes the 3 radiobuttons for the size and the other one includes the radiobuttons for the color. Use the If-structure to see what is checked so the program can change the outcome.


RE: VB.NET radio buttons help by Ezra on 11-04-2005 at 09:15 PM

How do you mean?

I tried it like this, but it doesn't work

code:
Function grootte()
        If (RadioButton1.Checked = True) Then
            MsgBox("button1")
        ElseIf (RadioButton2.Checked = True) Then
            MsgBox("button2")
        ElseIf (RadioButton3.Checked = True) Then
            MsgBox("button3")
        End If
    End Function

    Function kleur()
        If (RadioButton4.Checked = True) Then
            MsgBox("button4")
        ElseIf (RadioButton5.Checked = True) Then
            MsgBox("button5")
        End If
    End Function

RE: VB.NET radio buttons help by Kryptonate on 11-04-2005 at 09:31 PM

This works:

code:
Private Function grootte()
        If RadioButton1.Checked = True Then
            MessageBox.Show("button1")
        ElseIf RadioButton2.Checked = True Then
            MessageBox.Show("button2")
        ElseIf RadioButton3.Checked = True Then
            MessageBox.Show("button3")
        End If
    End Function

Private Function kleur()
        If RadioButton4.Checked = True Then
            MsgBox("button4")
        ElseIf RadioButton5.Checked = True Then
            MsgBox("button5")
        End If
    End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        grootte()
        kleur()
    End Sub


RE: VB.NET radio buttons help by Ezra on 11-04-2005 at 09:36 PM

Doesn't work for me.

If I click radiobutton2 and after that 5 for example it enables 5, not 2 anymore


RE: VB.NET radio buttons help by Kryptonate on 11-04-2005 at 09:40 PM

If you check 2 and then 5 and then press the button it shows 2 messageboxes. So it works, no?


RE: VB.NET radio buttons help by Ezra on 11-04-2005 at 09:43 PM

No, it only shows one messagebox, the button5 one


RE: VB.NET radio buttons help by Kryptonate on 11-04-2005 at 09:51 PM

Place the radiobuttons in 2 groupboxes. The first three in the first one and the other two in the other one. This is how I did it and it works.


RE: VB.NET radio buttons help by Ezra on 11-04-2005 at 09:56 PM

that's the way I have it too.

Btw, I added you on MSN, kryptonate@gmail.com

EDIT: Got it working YAY!

Thanks very Much Kryptonate (Y)