View Single Post
Old Feb 3rd, 2007, 3:24 AM   #9
PhilBon
Hobbyist Programmer
 
PhilBon's Avatar
 
Join Date: Nov 2005
Posts: 172
Rep Power: 4 PhilBon is on a distinguished road
Send a message via AIM to PhilBon Send a message via MSN to PhilBon
Alright. Let's go through the list of corrections you should make. #1 Do you know about a structure array? Because YOU SERIOUSLY need one. A structure array is an array of structures, where a structure can be a anything from a textbox, button, labels, etc. So what you should do is make a 2-D structure array of buttons and assign each button with an array value. This will help you out in many ways. The second thing you need to do is put everything you have for one button into a function. That way you only have to have the code once. You will need to pass in the values for the button so something like this:
vb Syntax (Toggle Plain Text)
  1. Function setTextValue(byref row as integer, byref col as integer){
  2. buttonarray(row,col).enabled = false
  3. Mapused(row,col) = true
  4. if xturn = true then
  5. buttonarray(row,col).text = "X"
  6. else
  7. buttonarray(row,col).text = "O"
  8. end if
  9. 'basically whatever you want in the function.
  10. }
This will help you. You could probably make this into a more object oriented design but I'm to lazy to help you with that. Now for the if statements:
vb Syntax (Toggle Plain Text)
  1. If mat(0, 0) & mat(1, 0) = mat(2, 0) Then
  2. MsgBox("You Win!")
  3. Else
  4. 'Should be:
  5. If (mat(0, 0) = mat(2,0)) and (mat(1, 0) = mat(2, 0)) Then
  6. MsgBox("You Win!")
  7. Else
I personally would take it from mat(0, 0) = mat(2,0) to be is mat(0,0) = "x" that way you are positive that it is correct, the reason for this is because there could be a chance mat(2,0) could be set to the wrong value.
PhilBon is offline   Reply With Quote