ThreadBoard ArchivesSite FeaturesActiveworlds SupportHistoric Archives |
[VB] Next Problem, lol: Combo Boxes (Sdk)
[VB] Next Problem, lol: Combo Boxes // SdkrobbieFeb 16, 2002, 9:27pm
This is a function I wrote to remove a given name from a combo box:
Function RemoveCit(CitName As String) For i = 0 To PresIdx If cbPresent.ItemData(i).text = CitName Then cbPresent.RemoveItem (i) End If Next i End Function PresIdx = the number of people in the list I've also tried removing the .text on cbpresent.itemdata(i) - if I remove it, it returns 0 which is invalid data and if I add .text I get invalid qualifier. Either way it crashes whenever someone leaves and for the life of me I cant work out why...*boggle* -Robbie baronFeb 16, 2002, 9:58pm
Function RemoveCit(AwSession As Long)
For i = 0 To PresIdx - 1 If cbPresent.ItemData(i) = AwSession Then cbPresent.RemoveItem (i) Exit For End If Next i End Function Itemdata can only store a *long*, never a string. It is a bad idea to remove items based on the name, always remove using the session# which is available during AW_EVENT_AVATAR_DELETE, if a bot leaves the area all with the same name will be removed. Also note that cbPresent.ItemData(PresIdx) is out of bounds since the array is zero based, hence the PresIdx-1. -Baron [View Quote] |