Click to See Complete Forum and Search --> : parallel arrays


Kvsk
February 19th, 2000, 08:13 PM
I need to place products and unit price in a list box straight across from each other as follows:
product1 $4.99
product2 $5.99 etc....

Both products and prices are in two separate arrays. how do I print them so the price is next to the product... someone please help... my code in form load follows... thanks.

Aaron Young
February 19th, 2000, 08:46 PM
Try this:
private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (byval hwnd as Long, byval wMsg as Long, byval wParam as Long, lParam as Any) as Long
private Const LB_SETTABSTOPS = &H192

private Sub Form_Load()
Dim iIndex as Integer
Dim aTabs(0) as Long
aTabs(0) = 70
Call SendMessage(List1.hwnd, LB_SETTABSTOPS, 1, aTabs(0))
for iIndex = 1 to 10
List1.AddItem "Product" & iIndex & Chr(9) & Format(Rnd * 100, "$##.##")
next
End Sub


Replacing the Sample Data with the Products and Prices from your Arrays, when you read the Values back from the List, the Product and Price with be seperated by a Tab, (Chr(9)).

Aaron Young
Analyst Programmer
ajyoung@pressenter.com
aarony@redwingsoftware.com
Certified AllExperts Expert: http://www.allexperts.com/displayExpert.asp?Expert=11884

Kvsk
February 20th, 2000, 09:20 AM
great...thank you...