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
Const LB_SETTABSTOPS = &H192
' Set tab stops positions for a ListBox control
' Each element of the array is expressed in dialog units,
' where each dialog unit is 1/4 of the average character width.
Sub ListBoxSetTabStops(lb As ListBox, tabStops() As Long)
Dim numEls As Long
numEls = UBound(tabStops) - LBound(tabStops) + 1
SendMessage lb.hwnd, LB_SETTABSTOPS, numEls, tabStops(LBound(tabStops))
End Sub
Värden i arrayen motsvarar 4 enheter. Följande exempel sätter ungefär stopp på tecknen 10,18 och 25
Dim tabs(2) As Long
tabs(0) = 40 ' 10*4
tabs(1) = 72 ' 18*4
tabs(2) = 100 ' 25*4
ListBoxSetTabStops List1, tabs()
När du har satt dina tabstoppar så adderar du bara nya rader till listboxen där varje objekt skall separeras med en vbTab så det blir rätt.
List1.AddItem "col 1" & vbTab & "col 2" & vbTab & "col 3" & vbTab & "col 4"