Four Columns in a DataTable need to be randomly assigned to four labels VB.NET


My problem is probably really simple and is as follows.

I have a data table full of questions.
They are in the following columns: ID, Question, CorrectAnswer, Incorrect1, Incorrect2, Incorrect3

It is for a multiple choice quiz.

I have four labels in a form: lblQ1, lblQ2, etc.

I need to randomly assign the location of my correct answer and then my incorrect answers.

I then need to be able to validate if the selected answer was the correct answer.

Any help much appreciated.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

This is somethign quick and dirty that I just knocked up that may give you a few ideas.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
	Dim Controls() As Control = {lblQ1, lblQ2, lblQ3, lblQ4}
	Dim Answers() As String = {CorrectAnswer, Incorrect1, Incorrect2, Incorrect3}
	Dim MuddledControls As New Generic.SortedList(Of Guid, Control)(Controls.Count)
	For Each Control In Controls
		 MuddledControls.Add(Guid.NewGuid, Control)
	For I As Integer = 0 To Answers.Count - 1
		 Dim Control = MuddledControls.Values(I)
		 Control.Text = Answers(I)
		 Control.Tag = If(I = 0, "Correct", "Incorrect")
	Next I
End Sub
Private Sub CheckAnswer(ByVal sender As Control, ByVal e As System.EventArgs) Handles lblQ1.Click, lblQ2.Click, lblQ3.Click, lblQ4.Click
	If sender.Tag = "Correct" Then
		MsgBox("Correct Answer!")
		MsgBox("Incorrect Answer!")
	End If
End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
olifaragoAuthor Commented:
Perfect thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.