|
-
Sep 29th, 2000, 03:19 PM
#1
Thread Starter
Member
I need to know if any occurance of a list box contains the string "Black". So far, I found out to find the first occurance, but if there are multiple items in a list box, I don't want to test each individual item in a list. There must be an easier way. My code so far:
Code:
If Ink.List(0) = "Black" Then
MsgBox "test succeed"
End If
I don't want to:
Code:
If Ink.List(0) = "Black" or Ink.List(1) = "Black" Then
MsgBox "test succeed"
End If
Thank you for any help.
Jim
"...head is all empty and I don't care..."
-
Sep 29th, 2000, 03:46 PM
#2
Frenzied Member
You don't want to check each listbox entry individualy, but how about a loop to check it? it's not that much work!
Code:
Private Sub Form_Load()
Static x As Long
'Add some stuff
List1.AddItem "jop"
List1.AddItem "JPRoy392"
List1.AddItem "black"
List1.AddItem "white"
List1.AddItem "green"
'Loop trough all listItems
For x = 0 To List1.ListCount
If List1.List(x) = "black" Then
'If black then show
MsgBox "Listbox item " & x & " is black"
End If
Next
End Sub
Have fun!
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Sep 29th, 2000, 03:49 PM
#3
Frenzied Member
Oh and if you really insist not checking all the listbox items you always have the api!
http://www.mvps.org/vbnet/code/lista...glistitems.htm
Hope I was of any help to you!
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|