‘declaration
Private Declare Function SendMessageByNum Lib “user32″ Alias “SendMessageA” (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Const LB_SETHORIZONTALEXTENT = &H194
‘form code
Dim s As String
Static x As Long
s = InputBox(“Please enter any text”, “List scroll”, “this is a simple scrollbar sample for demonstration purposes”)
List1.AddItem s
If x < TextWidth(s & “ “) Then
x = TextWidth(s & “ “)
End If
If ScaleMode = vbTwips Then
x = x / Screen.TwipsPerPixelX ‘ if twips change to pixels
SendMessageByNum List1.hwnd, LB_SETHORIZONTALEXTENT, x, 0
End If