How do I separate the single line of input into 3 different variables without using arrays? (x,y,z) Each section is separated by a space
Ex. 184 41890 42891
The code I have so far is just reading the line one character at a time in a loop.
c = Chr(reader.Read)
s = ""
Do While (ch <> vbCr) And (ch <> Chr(32)) And (reader.Peek <> -1)
Select Case c
Case "0" To "9"
s = s & c
Case Else
MsgBox("Error")
End Select
c = Chr(reader.Read)
Loop
Do you want to avoid using arrays altogether or just end up with the parts in specific strings? You can do this:
string input = "184 41890 42891";
string[] parts = input.Split(' ');
string myCustomString1 = parts[0];
string myCustomString2 = parts[1];
string myCustomString3 = parts[2];
This has problems though because you need to know how many parts there will be so that you can have enough strings set up. The advantage of arrays is that they are flexible and can be whatever size you wish.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments