Hello, How could I ensure that the data entered in the following code is numerical? Console.Write(CurrentPlayer & " enter x coordinate: ") XCoordinate = Console.ReadLine() Console.Write(CurrentPlayer & " enter y coordinate: ") YCoordinate = Console.ReadLine() Console.WriteLine() Code (markup): Many Thanks, Anhalo.
if IsNumeric(something) then // do something End If Code (markup): I don't have VB.NET installed at the moment. But that'll work.
Generally you will want to use the TryParse method - so if its an interger, you would do: Dim testStr as string = "34" Dim val as Integer if (Integer.TryParse(testStr, val)) then ' we have a valid val casted as an int ready to go end if