hi all.
I've been trying to make a basic version of mine sweeper. when i ran the program it did not give me all the expected outputs. i have tracked back the error to this bit of code that i have eddited down to just the bits that dont run and the context in which the code makes sence... can anyone see the problem
Dim Xlength As Integer = 5 - 1, _
YLength As Integer = 5 - 1, _
chosen(0 To Xlength, 0 To YLength) As Boolean, _
value(0 To Xlength, 0 To YLength) As Integer, _
NoOfMines As Integer
Private Sub set_board() Handles Me.Load
NoOfMines = (((Xlength + 1) * (YLength + 1)) ^ 0.5) - 1
For FirstD As Integer = 0 To Xlength
For SecondD As Integer = 0 To YLength
chosen(FirstD, SecondD) = False
value(FirstD, SecondD) = 0
Next
Next
Dim RandomD1, RandomD2 As Integer
Randomize()
For counter As Integer = 1 To NoOfMines
Do
RandomD1 = Rnd() * Xlength
RandomD2 = Rnd() * YLength
Loop Until chosen(RandomD1, RandomD2) = False
chosen(RandomD1, RandomD2) = True
Next
Dim number As Integer
For FirstD As Integer = 0 To Xlength
For SecondD As Integer = 0 To YLength
If chosen(FirstD, SecondD) = False Then
number = 0
For X As Integer = -1 To 1
For Y As Integer = -1 To 1
If chosen(FirstD + X, SecondD + Y) = True Then number += 1
Next Y
Next X
value(FirstD, SecondD) = number
Else
value(FirstD, SecondD) = -1
End If
Next SecondD
Next FirstD
End Sub
i have tryed message boxing parts out and it seems to just stop funning the code at If chosen(FirstD + X, SecondD + Y) = True Then number += 1. MS visual basic 2010 is not giving me any errors, can anyone help me out