:eek: This is the strangest thing. The program ignores all of my for loops in this method. I double checked the syntax and everything. Am I missing something?
BTW, I know that it skips those, because I tell it to play a sound when it enters, and it doesn't play the sound...HOWEVER, if i put the play sound statement outside of the loop (directly after the method is declared), it plays it...wat is going on?:sad:

public bool MoveValid(int col, int row, int val)
{
for (int r = 1; r == 9; r++)
{
splayer.Play();
if (actual[col, r]==val)
{
return false;
}
}
for (int c = 1; c == 9; c++)
{
if (actual[c, row] == val)
{ return false;}
}
int StartC, StartR;
StartC= col -((col-1)% 3);
StartR = row - ((row - 1) % 3);
for (int rr = 0; rr == 2; rr++)
{
for (int cc = 0; cc == 2; cc++)
{
if (actual[StartC + cc, StartR + rr] == val)
{
return false;
}
}
}
return true;
}

lets look....

for (int r = 1; r == 9; r++)

r==9 is your problem which returns false in the first run. (r=1)

try < or <= according to your needs...

Heh heh...

I never would've guessed (I'm new to C# so I'm still to learn how to properly use the syntax) While you're at it, whats is the correct way to do a step in the for loop? Like if I wanted it to add 3 to the iterator every loop it does...I tried

for (r=1, r<9; r+3)

, but the IDE rewarded me with a shiny new compile error...any thoughts?

in c# i++ means (not totally equal but) i+=1 which also equals i=i+1 so if you want 3 step you can use i+=3 or i=i+3

nice. thanks man.

concerning the for-loop, try to remember that the second parameter, in our case somthing like

r <= 9

is a condition that is checked everytime the loop repeats and not an 'execute till ...'-condition.

hope this helped
pygmalion

help me to make a program that has three equation and three unknown i dont have idea thats why i nedd help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.