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

Fixed Length String

Status
Not open for further replies.

ToshTrent

Technical User
Jul 27, 2003
209
Hi,

I am calling values from an array and popping them into the listbox control. I was wondering does anyone know how I can make the strings I am adding a fixed length. This will enable me to make a well organised list.

So I wana do the below example

Short Another Word
AlongWord Another Word

[red]
Thankyou[/red]
Matt
 
You can do this by playing with padding, BUT..... it will only work if you use a mono-space font. Because i and W take up a diferent number of pixels in width in most common fonts, using spaces as padding won't line up the text.

Do a search here and on google for a multi-column or two-column list or combo box.

-Rick

----------------------
 
Thank you for your help Rick, as I have been instructed to use simple methods I will use the padding-right option. Looks like i'm stuck to New Courier font for the listbox, what a lame font it is! lol


[red]
Thankyou[/red]
Matt
 
Weel, the easiest way would be something like:

Code:
word1=Word1.substr(0,9) 
word2=Word2.substr(0,9) 
word3=Word3.substr(0,9) 
sValue = Word1 & spc(10-word1.len) & word2 & spc(10-word2.len) & word3 & spc(10-word3.len)

It'll crop the words, and it'll only work for mono-spaced fonts, but it's quick and easy.

-Rick

----------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top