Hey, whenever I compile the code below the program compiles and runs but after a while I get the following error:
System.IndexOutOfRangeException was unhandled
Index was outside the bounds of the array.
Also, when compiling I get the following: A first chance exception of type 'System.IndexOutOfRangeException' occurred in array_mult.exe
The compiler points at
NumberA(i) = Val(NumberA_Char(i))
I don't see why this is happening because 'i' is at max 31, which is acceptable. What I wanted was to read and store numbers in a char array and then convert each element of the char array to int and then store it in the corresponding element of the byte array.
Thanks for reading.
Module Module1 Sub Main() Dim NumberA(31) As Byte Dim NumberA_Char(31) As Char Dim NumberB(31) As Byte Dim NumberB_Char(31) As Char Console.Write("NumberA_Char: ") NumberA_Char = Console.ReadLine() Console.Write("NumberB_Char: ") NumberB_Char = Console.ReadLine() For i = 0 To 31 NumberA(i) = Val(NumberA_Char(i)) NumberB(i) = Val(NumberB_Char(i)) Next Console.Write("NumberA: ") For i = 0 To 31 Console.Write(NumberA(i)) Next Console.WriteLine() Console.Write("NumberB: ") For i = 0 To 31 Console.Write(NumberB(i)) Next Console.ReadLine() End Sub End Module