Valhalla Legends Forums Archive | Visual Basic Programming | Element Not Found

AuthorMessageTime
laurion
I'm getting element not found when i do
[code]
Private Sub oscarSock_loggedOut(strFormattedName As String)
lstUsers.ListItems.Remove strFormattedName
End Sub
[/code]
and to raise it,
[code]
Case 4
pData 2, getTLV(strData, 1) 'store formatted name
A1 = Split(getTLV(strData, 5), ":", 2)
pData 3, getTLV(strData, 6)
pData 4, getTLV(strData, 17)
Winsock1(1).Close
Winsock1(1).Connect A1(0), A1(1)
RaiseEvent loggedOut(CStr(getTLV(strData, 1)))
[/code]
Whats wrong? I even tried the lstusers part with parenthesees, still nothing
August 9, 2004, 7:29 PM
CrAz3D
You are supposed to remove users by an index, not a string. You are trying to remove them by a string.
August 9, 2004, 9:22 PM
laurion
does that mean I have to add each one with an index?
August 10, 2004, 1:45 AM
Eli_1
Note: People who know me, know that I have a hard time expressing things in words. I'll try my best to explain it, but bare with me.


Think of it more as an array.

Dim Blah(9) as String

That has a total of 10 different elements (0-9), and 10 different indexes.

Suppose each one of those (Blah(0) - Blah(9)) contains a person's name. One of them is "laurion." How would you search through that array and find the index that corresponds with that name? Most likely, you would use some kind of loop, and compare each element in the array to the name you're searching for to find the correct index which holds that name.

The same could be applied to a listview. Each name you see on a channel list has it's own corresponding index. To remove an item from that listview, you need to pass the index you want removed to the Remove function.
August 10, 2004, 2:20 AM
Myndfyr
[quote author=Eli_1 link=board=31;threadid=8094;start=0#msg74832 date=1092104456]
[code]
Dim Blah(9) as String
[/code]
That has a total of 10 different elements (0-9), and 10 different indexes.
[/quote]
Actually, no -- that has a total of 10 different elements, and ten different indices. The indices are 0-9 -- the elements are not. The elements are referenced to by the indices as appropriate (and really, the elements are not referenced directly by numerical indices, but by the size of offset of one element to the next times the index into the array, but who's counting?)

The rest was right though :)
August 10, 2004, 2:46 AM
Eli_1
Oops, thanks for correcting my wrong information. ;D
August 10, 2004, 4:58 AM
Myndfyr
[quote author=Eli_1 link=board=31;threadid=8094;start=0#msg74849 date=1092113902]
Oops, thanks for correcting my wrong information. ;D
[/quote]

I got yer back. I'm your support. Just call me bra. Er, bro.
August 11, 2004, 12:58 AM
ChR0NiC
Don't forget we kind of discussed this matter here
August 15, 2004, 9:06 PM
Newby
[quote author=laurion link=board=31;threadid=8094;start=0#msg74766 date=1092079759]
I'm getting element not found when i do
[code]
Private Sub oscarSock_loggedOut(strFormattedName As String)
lstUsers.ListItems.Remove strFormattedName
End Sub
[/code]
[/quote]
Should be something like:

[code]Private Sub oscarSock_loggedOut(strFormattedName As String)
listUsers.ListItems.Remove(listUsers.FindItem(strFormattedName).Index)
End Sub[/code]
August 17, 2004, 12:44 AM

Search