i write this code to work with some radio button and calculate Score for a questionare :
Dim SScore As Byte = 0
Dim BTNN As Byte = 0
Dim BTNNS As String = ""
For Each rBTN As RadioButton In Me.Controls
If Mid(rBTN.Name, 1, 5) = "RBS01" Then
If rBTN.Checked Then
SScore = SScore + CType(Mid(rBTN.Name, 7, 1), Byte)
End If
End If
Next
I get this error on line 4 :
Unable to cast object of type 'System.Windows.Forms.Button' to type 'System.Windows.Forms.RadioButton'.
i dont know what is it and how can handle it. please help me.
Dim SScore As Byte = 0
Dim BTNN As Byte = 0
Dim BTNNS As String = ""
For Each rBTN As RadioButton In Me.Controls
If Mid(rBTN.Name, 1, 5) = "RBS01" Then
If rBTN.Checked Then
SScore = SScore + CType(Mid(rBTN.Name, 7, 1), Byte)
End If
End If
Next
I get this error on line 4 :
Unable to cast object of type 'System.Windows.Forms.Button' to type 'System.Windows.Forms.RadioButton'.
i dont know what is it and how can handle it. please help me.