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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ComboBox syntax to find an item in the list

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
0
36
US
using VB6
I am loading a database worth of stuff in a combo box. approx 150 records.
Here is one item using the Add item

MARCRAFT CORPORATION |02/14/01|1Z3670450250342860|PO-11427|00890034

which consists of Comapny name| Date | UPS tracking # | PO | Order number

Each field is separted by a Pipe Symbol
I want to find the order number "00890034 in my example" somewhere down the list in the combo box and highlite it.
I don't know which thign to use
List(x) ItemData
Is there a FAST way to find 00890034
I know I need to use
for a = 0 to combo1.Listcount
right(Combo1.???? , 8)
'maybe more code here
next

but what can I use in place of the Question marks ????

TIA
DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
First of all, if you try to loop from 0 to ListCount, you'll go one step too far. Try this:

for a = 0 to combo1.ListCount - 1

Second, the property you're looking for is List. IE:

If Right(Combo1.List(a),8) = "00890034" Then
'Do whatever...

Really though, if you're dealing with a database, it would be better to do a Find on a Recordset pointing to it...
 
Great
I thought about just finding it in the recordset again but since I already had it in the Combo box I thought it might be easier.
Anyway

I have this now but...

For a = 0 To Combo1.ListCount - 1
If Right(Combo1.List(a), 8) = Text4 Then
combo1.select-a-roony
Next

How do I select item 12 say if that what "a" is.
I have the On_click event of the combo box set to do something else.
So If I can programitacally select it, it should trip the On_click event and bingo.

TIA

DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Try setting the ListIndex property of the combo box.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top