I have a string called "Alias". Basically when a user quits the program I need lstUsers list to remove the value of "Alias" from the list. How do I do that???
Printable View
I have a string called "Alias". Basically when a user quits the program I need lstUsers list to remove the value of "Alias" from the list. How do I do that???
VB Code:
Dim indx As Long 'If you wan't to remove [b]all[/b] instances of "Alias" For indx = List1.ListCount - 1 To 0 Step -1 If List1.List(indx) = "Alias" Then List1.RemoveItem indx Next 'Or 'If you wan't to remove [b]one[/b] instance of "Alias" Dim indx As Long For indx = List1.ListCount - 1 To 0 Step -1 If List1.List(indx) = "Alias" Then List1.RemoveItem indx Exit For End If Next
You may have to watch your CAPS in comparing strings. I have had trouble in the past where "Alias" is not the same as "alias".
If you know uppercase/lowercase the text is in then you are OK otherwise use the Ucase() function to change both strings to the same case.
I said I made a varaible called Alias. Alias is the var! its contents are what im removing, not the word Var....just cauz im a Junior Member dosnt mean i dont know some programming stuff....
OK I guess we both misread your post. Use Bruce Fox's code but put your variable at the correct place and be careful of upper and lowercase characters.
I remember being junior once.
Yea I'm getting there....
Thanks for the heads up anyways i found the " around the word Alias in Brute's code and deleted them. The code works wonderfully now!