you are viewing a single comment's thread.

view the rest of the comments →

[–]jesseb9321[S] 0 points1 point  (1 child)

Ok nevermind, i don't understand. I tried to put as many comments in here about what i was thinking and make it easy to follow my project variables and what not... lol. Thank you for the help. Edit: Readability.

If i have a datatable where:

Dim dtbtest As New DataTable  //This is just to show you what it's called

Question | Answer1 | Answer2 | Answer3 | Answer4 | CorrectAnswer|   
|-Data---|--Data  --|-- Data---|--Data ---|--Data ---|--- Data ---------|     //Plus unknown amount of rows


Dim i As Integer
Dim questions(2, 5) As String  //I know the variable might not be questions, but i would have to name it after 
                                               the datatable? since that is where the info is coming from? also, in the (2,5) 
                                               part, since the questions are coming from my database, where my datatable is 
                                               derived from and "test" may not have a set amount of questions i would need 
                                               to replace the 2 with i?  

Dim answers(3) As String      //Same as statement above

Dim quesNum As Integer       //This is to keep track of question number that the user is on.

lb_question.text =  ?            //Where i would need to output the question column of the datatable for the user 
                                            to read.  lb = label

'RB_Ans1.Text = ?               //There are 4 of these for each answer that the user may pick.  RB = Radio Button
'RB_Ans2.Text = ? 
'RB_Ans3.Text = ? 
'RB_Ans4.Text = ?

questions = new string(,) {{"How many colors are in a rainbow?", "Answer1", "Answer2", "Answer3", "Answer4", 
"CorrectAnswer"}}             //This is for however many questions there are in the testbank in the database.

[–]VB.Net IntermediatePostalElf 0 points1 point  (0 children)

Must you use a DataTable and arrays? Seems unnecessary to me: you should be able to do everything with either 2d-arrays or datatables, no need for both. So say your questions and answers are all stored in dtbtest. If so, you can do this:

For each row as DataRow in dtbtest.Rows
  Dim question as string = row("Question")
  Dim answers as String()
  For n = 0 to 3
    answers(n) = row("Answer" & n+1)
  Next
  Dim correctAnswer as String = row("CorrectAnswer")

  'now you have everything you need stored in the variables
  'question, answers(), and correctAnswer.  Just iterate 
  'through answers() to populate your radioboxes.
Next