Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to tell if a list box has been clicked 2

Status
Not open for further replies.

gwar2k1

Programmer
Apr 17, 2003
387
0
0
GB
Im writing validation and i have a button that removes an item from a list box. Obviously if the list isnt populated or a selection within the list hasnt been made, an error occurs... Im using this code which resolves the empty list problem but not the highlightedness:

Code:
If (lst2.ListCount <> 0) Or (lst2.Selected = False) Then
  lst2.RemoveItem (lst2.ListIndex)
End If

can any one tell me what im doing wrong? merci

TIA


~*Gwar3k1*~
&quot;To the pressure, everything's just like: an illusion. I'll be losing you before long...&quot;
 
Cool thanks =D star for speedyness + effectiveness

~*Gwar3k1*~
&quot;To the pressure, everything's just like: an illusion. I'll be losing you before long...&quot;
 
hmm... it doesnt like that actually.

if lst2.listindex <> -1 then
remove...

~*Gwar3k1*~
&quot;To the pressure, everything's just like: an illusion. I'll be losing you before long...&quot;
 
If you do this it doesn't work?

Private Sub lst2_Validate(Cancel As Boolean)
If lst2.ListIndex <> -1 Then
lst2.RemoveItem lst2.ListIndex
End If
End Sub

&quot;Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'.&quot;
 
nope:

Code:
Private Sub btn2_Click()

If (lst2.ListCount <> 0) Or (lst2.ListIndex <> -1) Then
  lst2.RemoveItem (lst2.ListIndex)
End If

End Sub

Error: Runtime error 5: Invalid call or procedure or argument

~*Gwar3k1*~
&quot;To the pressure, everything's just like: an illusion. I'll be losing you before long...&quot;
 
Change to just:
If lst2.ListIndex <> -1 Then
lst2.RemoveItem (lst2.ListIndex)
End If
because when listcount is = to 3 it would be true but you can not remove item lst2.ListIndex = -1

&quot;Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'.&quot;
 
Cool thats great =)

~*Gwar3k1*~
&quot;To the pressure, everything's just like: an illusion. I'll be losing you before long...&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top