Valhalla Legends Forums Archive | .NET Platform | [SOLVED] VB.Net Split

AuthorMessageTime
Zer0
[code]
   Function enter_user_info(ByVal selected As String)
        Dim a() As String
        Dim linein As String = selected
        a = linein.Split(";")
        addUserName.Text = a(0)
        addUserLevel.Text = a(1)
        Return True
    End Function
[/code]

ok i have bee driving myself crazy all night over this, i finalyl got split to return A value. It is only returning one. The value of selected is
[code]Bla4;100[/code]

the error it spits at me is
[code]Index was outside the bounds of the array.[/code]
as if there isnt 2 values in the array. when obviusley there is.... or should be
October 14, 2006, 1:43 PM
Myndfyr
Set a breakpoint at the line "addUserName.Text = a(0)".  What's the value of a?
October 14, 2006, 7:38 PM
Zer0
a SHOULD be
[code]Bla4;100[/code]
split at ";"

so a(0) should be
[code]Bla4[/code]
and a(1) should be
[code]100[/code]

a(0) is set correctly, but a(1) is empty

--edit:
ok im not sure what i did but i got it to split correctly on load, but now when i try and delte a row (this is a listbox) it throws that same error at me the code im using to delete a row is
[code]
    Function remove_user()
        If userIndex.Text <> Nothing Then
            userDb.Items.RemoveAt(userIndex.Text)
            Return "User [ " + addUserName.Text + " ] removed from database."
        Else
            Return "User was not found in the database."
        End If
    End Function
[/code]

soo ne ideas on this one :p

---edit again

ok, i decided to look at this from a diffrent aproach on the delete part and got it working, i was tryong to splt info that wasnt there so now i got both parts working :)
October 14, 2006, 8:08 PM

Search