Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[blue]Option Explicit
Private Const LB_SETTABSTOPS = &H192
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 Declare Function MulDiv Lib "kernel32" (ByVal nNumber As Long, ByVal nNumerator As Long, ByVal nDenominator As Long) As Long
Const sChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
Private Function GetCalcRightMargin(myList As ListBox) As Long
Dim avg As Long
Dim oldfont As Font
Set oldfont = myList.Parent.Font
Set myList.Parent.Font = myList.Font
avg = myList.Parent.TextWidth(sChars) / Len(sChars)
Set myList.Parent.Font = oldfont
GetCalcRightMargin = -MulDiv(myList.Width - 4, 4, avg)
End Function
Private Sub Form_Load()
Dim TabArray(0) As Long
List1.AddItem vbTab & "Hello"
List1.AddItem vbTab & "This is an example"
List1.AddItem vbTab & "not complete"
TabArray(0) = GetCalcRightMargin(List1)
Call SendMessage(List1.hwnd, LB_SETTABSTOPS, 0&, ByVal 0&)
Call SendMessage(List1.hwnd, LB_SETTABSTOPS, 1&, TabArray(0))
List1.Refresh
End Sub[/blue]