Click to See Complete Forum and Search --> : ThrowIfOutOfRange(Idx) - totally confused


TerraNova
May 23rd, 2003, 01:13 PM
I am new to programming !!! as if you couldn't guess!!!
Have been trying to write a function for the following:
Valid if String begins with a Capital letter contains no space characters and has a length no longer than 8.

This is the code I wrote but continuously get the above and do not understand why and where I am going wrong!!

bool ValidName(AnsiString Name)
{
int I;
bool Good;
Good = false;
I = 0;

while ((!Good) && (I <= 8))
{
if ((Name[I] >= 'A') && (Name[I] <= 'Z'))
if (Name[I] != ' ')
Good = true;
I = I + 1;
return Good;
}
}

:confused: :confused: :(