vb help


Diabloii.Net Member
vb help

I know that there are a plethora of knowledgable peoples in this forum and I call upon you now to help me make.... Minesweeper!
I've got as much as I can going, but what I can just not figure out how to do is when you click on a square with no mines around it, to make it disappear and also take out all the other ones around it, that's the only hard part I can think about it; I've got a pseudo 2d array of command buttons acting as the squares(duh) but I just don't know how to start even thinking about the problem, any of you smart people I would greatly appreciate your help



Diabloii.Net Member
I'd be able to help u if u used java... i haven't programmed in vb for 4 years, and when i did, it was relatively elementary.

Do you have to do this in vb? If not, i suggest u switch to java.


Diabloii.Net Site Pal
Can you set a property to make the button invisible or change its style or something? Sorry, it's been about 5 years since I've touched VB.

If this doesn't have to be VB and you know C++, I'd suggest looking at the FLTK toolkit.

<total hack solution>
Change the button's position to somewhere where it can't be seen. This is by no means a good solution, but it might make things look ok while you work on getting the rest of your program to work.
</total hack solution>


Diabloii.Net Member
no clue about vb, but i cannot see the difference to the other buttons.

What happens if the user clicks on a button? I would guess some kind of function is called like
function click:
if (mine) then new game
else if (1) then buttontext = 1
else if (8) then buttontext = 8

now if you click an empty field, all you would have to to is make the text empty, and call the function on the fields around the one clicked.


Diabloii.Net Member
heh, to be honest it wasn't the vb which was giving me trouble, it was the theory behind it, and yea, I am forced to use vb.
I *think* I can work it, I'll try Jeda's solution, and get back to you people on it later today


Diabloii.Net Member
It's called the inside blank rule.

I actually had to program Minesweeper in a VB class years ago. What you do is this: If a square is clicked, and it's a mine, game over. If there's no mine, you check all the surrounding squares. Add and subtract 1 from the coordinates of the current square to easily check the surrounding ones, making sure of course not to attempt to check squares that don't exist.

If there are mines surrounding the square, you tally them up and then flip the tile, revealing the number of mines surrounding it.

Here's where it gets tricky. If there are no mines, the tile flips and displays a blank. Then you recursively call your 'mine check / tile flip function' on all the tiles surrounding the original click. So if you write that into the function, it'll automatically go until there are no more tiles to reveal.

Hope that helps!


Diabloii.Net Member
the way I've got it is it checks all the mines and makes the appropriate images to the squares when each new "level" loads, i just forget where, if anywhere, I have it recorded, what would be great in actual vb code would be to get an image's source file, cause that's all that's needed, but I'll do the try all the ones around it, too bad I'm not that good at recursion... I'll try it when I get back from prom, or wake up tomorrow, whichever

thanks people


Diabloii.Net Member
UserMathias said:
omg he dares to have a postcount related to "the game" in the otf. :uhhuh: burn him alive...

errr another thing why did you also mark the "vb" part of the topic, vb appreviates something else beside visual basic?

edit: ah missed the microsoft headline... ;)

back to topic: there's no need to be scared by recursion, in most cases a sheet of paper helps to look through the algorithm really easy


Diabloii.Net Member

I use 1 function to help with searching around where you click based on where you are(in the middle or a side) and it places the pictures appropriately, but when used in the exact same fashion it doesn't work for other things


Diabloii.Net Member
this is quite angering

using the function to find which squares are searchable around a square.... it'll go backwards, it'll do all crazy crap