Hi All,

How do i get user choice Radio button text from multiple radio button, When i save as word document.
Below code is what i did:

"Food :" & ComboBox1.Text & ", Quantity :" & txtCountFood & vbNewLine &

But instead of using ComboBox (as above code) i want to Use RadioButton1, RadioButton2, RadioButton3 :

"Food :" If RadioButton1.Checked = True Then
    RadioButton1.Checked = "Tomato, Quantity :" & txtCountFood & vbNewLine 
    ElseIf RadioButton2.Checked = True Then
    RadioButton1.Checked = "Tomato, Quantity :" & txtCountFood & vbNewLine
    ElseIf RadioButton3.Checked = True Then
    RadioButton1.Checked = "Tomato, Quantity :" & txtCountFood & vbNewLine
    EndIf

Nothing, came out of it except : Food :

Thank You.

Recommended Answers

All 5 Replies

       For i = 0 To 2
            Dim RadioButton As RadioButton = CType(Me.Controls("RadioButton" & i + 1), RadioButton)
            If RadioButton.Checked = True Then
                MsgBox("Food :" & RadioButton.Text & ", Quantity :" & txtCountFood)  'msgbox is example
            End If
        Next

Try This:

Dim orderString as String 

If RadioButton1.Checked = True Then
       orderString = "Food : " & RadioButton1.Text & ", Quantity :" & txtCountFood & vbNewLine
ElseIf RadioButton2.Checked = True Then
       orderString = "Food : " & RadioButton2.Text & ", Quantity :" & txtCountFood & vbNewLine
ElseIf RadioButton3.Checked = True Then
     orderString = "Food : " & RadioButton3.Text & ", Quantity :" & txtCountFood & vbNewLine
EndIf

Then get orderString variable.

@ ryanjayson
do you even understand my code before suggesting your solution!

@oussama 1
Yes, I do understand your code. Why?

Thanks you guys for your help, I tried :

        Dim rButton as string

        if  RadioButton1.Checked = True Then
        rButton = "Tomato , Quantity : & txtCountOrder.Text &", Price : " & lblResult1.Text & vbNewLine
        ElseIf RadioButton2.Checked = True Then
        rButton = "Potato , Quantity :" & txtCountOrder.Text &", Price : " & lblResult1.Text & vbNewLine
        .....
        .....
        ......
        EndIf

        "Food : " & rButton 
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.