hello jimscott
you use space your problem will be solved
List1.AddItem Space(5) & "sss" & Space(5) & "cc" & Space(5) & "cc" & Space(5) & "cc" & Space(5) & "cc"
Main Topics
Browse All TopicsI am using a listbox to display a number of items separated by vbTab. The first vbTab seems to jump approx 20 spaces where subsequent ones jump approx 5 spaces.
How can I change the first vbTab to be 5 spaces also ?
Anyone any ideas ?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
The tab character goes from one tabstop to the next tabstop. Tabstops are set up as 8 spaces, if the first word is 8 characters, then the tab will move the next item to offset 16.
If the first word on row 2 is 3 characters then tab will move the next item to offset 8. Tab doesn't put a fixed amount of space between each item, it moves to the next tabstop. You could use your own formatting like mahesh suggests with spaces instead of tabs. Another option is to use the ListView instead of the listbox. It is designed for multiple columns and you can add items to each column as opposed to trying to format them.
Hi,
Both Mahesh_mp and SRigney are correct, tabs are very poor at getting a list very straight. However, you can manipulate the distance of the tabstops themselfs with the SendMessage API.
There is a message specific for Listbox controls, it is named LB_SETTABSTOPS. This is used to specify tab stops in a listbox control. Tab stops are specified in dialog base units, which represent one-forth of the average character width.
For our example, I have chosen to use four tabs to demonstrate things. The code below will set tab stops at specified intervals.
Private Declare Function winSendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
Private Const LB_SETTABSTOPS = &H192
Private Sub Form_Load()
Dim aTabs(3) As Long
Dim lReturn As Long
Dim lCounter As Long
aTabs(0) = 20
aTabs(1) = 40
aTabs(2) = 60
aTabs(3) = 80
lReturn = winSendMessageLong(List1.h
For lCounter = 0 To 9
List1.AddItem "Text that is long" & vbTab & "with some more" & vbTab & "Tabs!" & vbTab & "!" & vbTab & "!"
Next
End Sub
In this example, the first tabstop is set at about 5 characters (20 divided by 4), the second at about 10 characters and so on. So, you can set the first tabstop to a reasonable large size, so it will look better.
Grtz.©
D.
Business Accounts
Answer for Membership
by: ampapaPosted on 2003-10-28 at 03:21:13ID: 9632889
Have you tried Tab(#)?