Please help. I need to take a string separated by commas, and divide up the numbers to store into an array. I cant seem to figure out why it isn't working. I'm pretty sure the part where I store the numbers is correct. It's just how I divide them up that is incorrect. Any help would be appreciated.
Code:
define variables
Dim usrInput(4) As Integer
Dim x As Integer = 0
Dim i As Integer = 0
Dim y As Integer = 0
Dim usrinput_ As String
'simplify input
usrinput_ = txtUserinput.Text
'find comma and split numbers
Do While x <= usrInput.GetUpperBound(0)
y = usrinput_.IndexOf(",", i)
If y = -1 Then y = usrinput_.Length
usrInput(x) = CInt(txtUserinput.Text.Substring(i, y - i))
i = y + 1
x += 1
If i = usrInput.GetUpperBound(0) Then
ReDim Preserve usrInput(usrInput.GetUpperBound(0) + 1)
End If
Loop