syntax help

Slurpee

Member
Joined
Apr 19, 2003
Messages
15
Im trying to generate a game board for a connect four project. Ive look long and hard for info on graphics within dot net but Ive had little luck. I was however fortunate enough to com across this solution based on vb6 code.

Code:
For a = Image1(Index).Index To 42 Step 7
                For b = 1 To 7
                    If LegalMoves(b) = a Then GoTo 300
                Next
            Next
now my question is: is this posiable within the .net? as Im having no luck at the moment :(
well I hope someone helps me out soon as Im off to purchase Deitel&Deitel (the best tech books ever)

cheers:D

[edit]VB is not PHP[/edit]
 
There are a few things about this VB6 snippet that should be
pointed out.

1.) Control arrays are no longer supported in VB.NET like they
were in VB6, so you cannot loop like this. Its also a very
redundant loop statement, because youre accessing the Index of
an Image control whose Index you already know.

2.) The use of GoTo is not acceptable to use in this way; a
subroutine should be created to handle the code, and then you
should call the sub.

That being said, I still dont understand what youre trying to
accomplish; if you want to draw graphics in VB.NET, look into the
System.Drawing namespace, and look at the sticky thread at the
top of this forum.
 
Bucky cheers for the reply :)
First off yes Im aware that this code is far from ideal, as I stated Im very new to vb.net and this is my very first attempt at graphics within this framework. I merely posted this code as I was fortunate enough to find a tutorial online that accomplished the task Im trying to solve ( a connect 4 game). The use of this loop is simply to populate the control (a 6,7 matrix). I was just curious if this code has a simple equivalent in .net Anyway cheers once again for the reply Im off to buy another text book that covers graphics in more detail than my prescribed text.
 
I would recommend against using many controls for this game, as they are unneeded, and since control arrays are unsupported (in the
forms designer, anyway), it will mean more code than you really
need. What you should do is use one single Panel control as the
main "playing surface" and then programatically check the MouseDown
events.

What you should do is create a 2-dimensional array at form level, and
store the values of each of the 42 spots (black, red, empty [or whatever])
in that. Then you can use the Panels MouseDown or MouseUp event
to both check the position of the point you clicked on, but also check
legal moves, check for winning combinations, etc.

If you want to use this method, you will need to read up on the
GDI+, which lives in the System.Drawing namespace. Remember though,
you should keep all your painting code in the _Paint event of the
panel, otherwise you may run into redrawing troubles.
 
Back
Top