I've got a listbox which show a series of integers. Is it possible to set the allignment of a listbox to right?
Printable View
I've got a listbox which show a series of integers. Is it possible to set the allignment of a listbox to right?
You can pad the numbers and artificially right-align them.
.Code:Dim I As Integer
For I = 0 To 100 Step 1
List1.AddItem Space(5 - Len(CStr(I))) & CStr(I)
Next
Thanx, that works just fine for me.
I just wrote a piece of code before this piece to determine the largest number on my list, so I could take that into account.
;)
Rick
If you don't want to go through your numbers calculating the length of the largest number, you can set up the number (5 which I have used) to something which will cover up for the maximum length in the selected data type. For e.g. if you are using integers, the maximum length could be 5 digits or 6 if you include the sign. So you can use 6 or 7 instead of 5 which I have used.
.