pgilfeather
asked on
How can I loop through multiple choice questions and check what ones have been answered?
How can I loop through multiple choice questions and check what ones have been answered?
Say I have radioList questions
RadQ1
a/ Possible Answer
b/ Possible Answer
c/ Possible Answer
d/ Possible Answer
RadQ2
a/ Possible Answer
b/ Possible Answer
c/ Possible Answer
d/ Possible Answer
RadQ3
a/ Possible Answer
b/ Possible Answer
c/ Possible Answer
d/ Possible Answer
RadQ4
a/ Possible Answer
b/ Possible Answer
c/ Possible Answer
d/ Possible Answer
RadQ5
a/ Possible Answer
b/ Possible Answer
c/ Possible Answer
d/ Possible Answer
Ok then Possible answer is the DataTextField and behind the scenes I have a,b,c & d set to either Correct or Incorrect as the DataValueField.
How can I check which questions have been answered. I have all the RadQ1,RadQ2 ID's displayed in labels so that they can be referred to by their ID...etc
I would like to basically fill in any unanswered questions automatically with an incorrect selections.
This question is very urgent and thus I would greatly appreciate your input
Thanks very much
Paul G
Say I have radioList questions
RadQ1
a/ Possible Answer
b/ Possible Answer
c/ Possible Answer
d/ Possible Answer
RadQ2
a/ Possible Answer
b/ Possible Answer
c/ Possible Answer
d/ Possible Answer
RadQ3
a/ Possible Answer
b/ Possible Answer
c/ Possible Answer
d/ Possible Answer
RadQ4
a/ Possible Answer
b/ Possible Answer
c/ Possible Answer
d/ Possible Answer
RadQ5
a/ Possible Answer
b/ Possible Answer
c/ Possible Answer
d/ Possible Answer
Ok then Possible answer is the DataTextField and behind the scenes I have a,b,c & d set to either Correct or Incorrect as the DataValueField.
How can I check which questions have been answered. I have all the RadQ1,RadQ2 ID's displayed in labels so that they can be referred to by their ID...etc
I would like to basically fill in any unanswered questions automatically with an incorrect selections.
This question is very urgent and thus I would greatly appreciate your input
Thanks very much
Paul G
ASKER
Thanks but this looks a bit over complicated, I'm sure there must be a much simpler way to do what I've asked. Also you have not made any regerence to my example.
Kind Regards
Paul G
Kind Regards
Paul G
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Imports System.Windows.Forms
Public Class clsControlID
Inherits System.Windows.Forms.Contr
' Return a reference to the control with the specified name,
' searched into the specified container and its sub-controls
' Note: it requires the GetAllControls function
'
' Example: get a reference to a Label named "lblTest", and set its Text property
' DirectCast(FindControl("lb
Public Overloads Shared Function FindControl(ByVal ctlName As String, ByVal container As Control) As Control
' retrieve an array with all the controls of the
' input container controls, and its sub-controls
Dim ctls() As Control = GetAllControls(container)
Dim ctl As Control
For Each ctl In ctls
' loop through the returned controls,
' and return the one with the
' wanted name, if present
If ctl.Name = ctlName Then Return ctl
Next
End Function
Public Overloads Shared Function FindControl(ByVal singleControl As Control, ByVal container As Control) As Control
Dim ctls() As Control = GetAllControls(container)
Dim ctl As Control
For Each ctl In ctls
If TypeOf (singleControl) Is TextBox Then
If ctl.Name Is singleControl.Name Then Return ctl
End If
Next
End Function
' Returns an array with all the controls in the specified container control and
' its child containers
' Example:
' ' print the name of all the controls on the form and its child container
' controls
' Dim ctl As Control
' For Each ctl In GetAllControls(Me)
' Debug.WriteLine(ctl.Name)
' Next
Shared Function GetAllControls(ByVal container As Control) As Control()
Dim al As New ArrayList
Dim ctl As Control
For Each ctl In container.Controls
GetAllControlsHelper(ctl, al)
Next
Return al.ToArray(GetType(Control
End Function
Shared Sub GetAllControlsHelper(ByVal
' add this control to the ArrayList
al.Add(container)
' add all its child controls, by calling this routine recursively
Dim ctl As Control
For Each ctl In container.Controls
GetAllControlsHelper(ctl, al)
Next
End Sub
End Class