On Oct 15, 7:40*pm, "Fred Blair" <passp...@thetr avelintexans.co m>
wrote:
I am trying to use Radio Buttons to *record a student's choice on a multiple
choice test. *I am using the MouseClick event to then put the choice into a
textbox. *This is just to learn about radio buttons. After I get this
figured out then the choices will go into an array to save until the testis
completed for scoring.
My code is below, but nothing appears in the textbox when I click on a radio
button.
Advice please,
Fred
*************** ****Code below********** ************
OPrivate Sub Form1_MouseClic k(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles Me.MouseClick
If RadioButton1.Ch ecked = True Then
TextBox1.Text = "A"
ElseIf RadioButton2.Ch ecked = True Then
TextBox1.Text = "B"
ElseIf RadioButton3.Ch ecked = True Then
TextBox1.Text = "C"
ElseIf RadioButton4.Ch ecked = True Then
TextBox1.Text = "D"
End If
End Sub
Hi,
Me.Click is fired when you clicked somewhere on your form except your
radio buttons, to fire radio button's checkedChanged event, i'm afraid
you need to create seperate events subs for each radio button as
follows:
'------------------------------
Public Class Form1
Private Sub RB1_CC(ByVal sender As System.Object, _
ByVal e As System.EventArg s) _
Handles RadioButton1.Ch eckedChanged
If RadioButton1.Ch ecked = True Then
TextBox1.Text = "A"
End If
End Sub
Private Sub RB2_CC(ByVal sender As System.Object, _
ByVal e As System.EventArg s) _
Handles RadioButton2.Ch eckedChanged
If RadioButton2.Ch ecked = True Then
TextBox1.Text = "B"
End If
End Sub
Private Sub RB3_CC(ByVal sender As System.Object, _
ByVal e As System.EventArg s) _
Handles RadioButton3.Ch eckedChanged
If RadioButton3.Ch ecked = True Then
TextBox1.Text = "C"
End If
End Sub
Private Sub RB4_CC(ByVal sender As System.Object, _
ByVal e As System.EventArg s) _
Handles RadioButton4.Ch eckedChanged
If RadioButton4.Ch ecked = True Then
TextBox1.Text = "D"
End If
End Sub
'-------------------------------
End Class
Hope this helps,
Onur Güzel