Call List3.AddItem(txtname & vbTab & txtamount & vbTab & txtqan & _vbTab & Format$(ans, "Currency"))

need help need to align the text the keep displaying like this:

toy car 1 $3.00 $3.00
card board box1 $0.50 $0.50
remote control car 1 $3.00 $3.00
cart 1 1 $1.00 $1.00

this is just the sample need it to look clean need help please the out put must be:

toy car 1 $3.00 $3.00
card board box 1 $0.50 $0.50
remote control car 1 $3.00 $3.00
cart 1 $1.00 $1.00

Recommended Answers

All 2 Replies

These two lists looks both the same. I guess this web didn't formated them well, so I don't now, what do you want to do with them exactly, but if you just want to make the lists aligned into nice columns, then try:

1) Right click on listbox and choose properties
2) Check gridlines (optionally, you'll see the cells then)
3) Set the view combo on value 3 - Report (thats necessary)
4) Set label edit on Manual (optionally, in the other case the first cell is editable by user as I remember)
5) Click on the "Column headers" tab and click four times on Insert column (necessary if you want to use my code below)
6) You can also name your columns, set their width, ...

then, for filling the list, use this:

Dim itmLIST3 As ListItem

Set itmLIST3 = List3.AddItem(txtName)
itmLIST3.SubItems(1) = txtamount
itmLIST3.SubItems(2) = txtqan 
itmLIST3.SubItems(3) = Format$(ans, "Currency")

This should work...

the code you are using is for the VBA Listbox control found in Excel, access, etc. and while it is usable from VB6, it is not redistributable...

There are two ways in which to accomplish what you want...
1.) Use a listview control.
2.) Do a bit of subclassing on the listbox. See...

Good Luck

commented: get it solve my problem thx for the tip i used method 2 +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.