keith wood

keith wood

  • NA
  • 3
  • 0

basic use of arrays

Jun 22 2007 4:09 PM
I'm having a problem with a project I'm attempting to create and was wondering if someone could help me. I'm trying to create a sudoku-like game and am only stumped when it comes to displaying incorrect user responses. I've attempted to use an array to store values of button.text numbers with incorrect responses, but don't know how to vary the length of the array depending on the number they answer incorrectly.

If Integer.Parse(btn1.Text) <> answers(0) Then

numberwrong += 1

btn1.BackColor = Color.Red

btn1check = True

wronganswer(0) = 1

This is an example of a code block that'll check every square. The wronganswer array is where I was hoping to store my incorrect answers. I've been instructed to simply put a msgbox within the if statement that checks each square. If the user were to answer all 81 boxes incorrectly, there'd be 81 message windows open and I'm not one to swamp my users in that fashion. Is there a way to redim the array by the number of another variable in a way like:

ReDim wronganswer(numberwrong)

so I have wronganswer() with the numberwrong number of dimensions? Even if I can figure out how to do that, is there a way to dynamically reproduce that in the msgbox for which buttons are actually incorrect?


Answers (3)