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.

Edited 2 Years Ago by missy_mi

       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.

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 

Edited 2 Years Ago by missy_mi

This question has already been answered. Start a new discussion instead.