' This program works with Dialog Units -- basically dividing a listbox into ' Functions and Constants Above Global Module
Public Declare Function SendMessage Lib "USER32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
Public Declare Function GetDialogBaseUnits Lib "USER32" () As Long
Public Const LB_SETTABSTOPS = &H192
' Make this a Public Subprocedure of the Global Module ' Note that we're dealing with Option Base 1 -- which may change Sub SetTabStops(lListWindowHandle As ListBox, iNoTabStops As Integer, lTabPositions() As Long)
Dim iIndex As Integer' Index into array of tab stops Dim lDialogBaseUnits As Long' Dialog base units Dim iDialogUnitsX As Integer' Horizontal dialog base units ' Obtain the dialog base units
lDialogBaseUnits = GetDialogBaseUnits()
iDialogUnitsX = (lDialogBaseUnits And &HFFFF&) \ 4
' Calculate the "required" tab positions ReDim lTabPos(1 To iNoTabStops) As Long
For iIndex = 1 To iNoTabStops
lTabPos(iIndex) = lTabPositions(iIndex) * iDialogUnitsX * 2
Next iIndex
' Set the required tab positions in the list box, ' by calling the "SendMessage" api and passing the ' handle of the listbox and details of the number of ' tabs and their positions. Call SendMessage(lListWindowHandle.hWnd, LB_SETTABSTOPS, CLng(iNoTabStops), lTabPos(1))
End Sub
' Code below in the Form_Load subprocedure sets up the tab stops in a listbox Dim lTabPos(3) As Long
lTabPos(1) = 30' Option Base 1 lTabPos(2) = 36
lTabPos(3) = 46
SetTabStops lstEntries, 3, lTabPos()' lstEntries is name of listbox