Valhalla Legends Archive

Programming => General Programming => .NET Platform => Topic started by: Zer0 on October 14, 2006, 08:43 AM

Title: [SOLVED] VB.Net Split
Post by: Zer0 on October 14, 2006, 08:43 AM

   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


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
Bla4;100

the error it spits at me is
Index was outside the bounds of the array.
as if there isnt 2 values in the array. when obviusley there is.... or should be
Title: Re: VB.Net Split
Post by: MyndFyre on October 14, 2006, 02:38 PM
Set a breakpoint at the line "addUserName.Text = a(0)".  What's the value of a?
Title: Re: VB.Net Split
Post by: Zer0 on October 14, 2006, 03:08 PM
a SHOULD be
Bla4;100
split at ";"

so a(0) should be
Bla4
and a(1) should be
100

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

    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


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 :)