For this tip add a list box and a command button to
your form. Then cut and paste the code below. Run
the program and click on the command button, all the
list items should now line up evenly.
Note: This will not work if you have the ListBox style
property set to CheckBox - 1
===================================================
Private Declare Function SendMessage Lib "User32" _
Alias "SendMessageA" (ByVal hWnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long
Private Const LB_SETTABSTOPS = &H192
Private Sub Command1_Click()
Dim ListBoxTabs(2) As Long
Dim result As Long
'Set the tab stop points.
ListBoxTabs(1) = 75
ListBoxTabs(2) = 150
'Send LB_SETTABSTOPS message to ListBox.
result = SendMessage(List1.hWnd, LB_SETTABSTOPS, _
UBound(ListBoxTabs) + 1, _
ListBoxTabs(1))
'Refresh the ListBox control.
List1.Refresh
End Sub
Private Sub Form_Load()
'Add a few items to the ListBox.
List1.AddItem "January Sales" & vbTab & _
"February Sales" & vbTab & _
"March Sales"
List1.AddItem "50" & vbTab & _
"500" & vbTab & _
"5000"
End Sub