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

Formating a list Box 3

Status
Not open for further replies.

itmasterw

Programmer
Apr 13, 2003
147
US
Hi,
I have records from a database going to a list box that looks as follows:
Bill Edwards 3nm The service was good Customer Service
KELLER CATHERINE L 4b63 They were good They were good.

I woulds like to format htis some how to look like this:

Bill Edwards 3nm The service was good Customer Service
KELLER CATHERINE L 4b63 They were good They were good.

That is each column lined up right.
any ideas would be appreciated.
Thanks
 
There are a couple ways to accomplish this.
One, the hard way is to identify the ideal length of each "column" and write a function to pad each string with spaces to fit that ideal length.

The second, better way is to use the ListView object instead of the ListBox.

There are plenty of examples out there of how to use a ListView.

_______
I love small animals, especially with a good brown gravy....
 
I would use a datagrid, if I were you. And if you are concerned about the look of it, you can always make the headers and the grid lines invisible.
However, if you really must use a list box, and if this list box is wide enough under all circumstances, then here is my suggestion:
Compose each line using tab spacing CHR(9) or vbTab instead of column spacing, with the hope that text length difference is not too big.
This works to a certain limit. vbTab makes about five characters worth tabulation, so you might need to decide on one or two vbTab each time depending on string portions.



Eman_2005
Technical Communicator
 
> vbTab makes about five characters worth tabulation

By default. However, you can change the tab settings with an API call ...

Having said that, a listview or a Forms 2.0 listbox are probably easier
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top