Private Sub Form_Load()<br><br> Dim i As Integer<br><br> For i = 1 To 100<br><br> List1.AddItem CStr(i) & _<br><br> " bottle(s) of beer on the wall."<br><br> Next i<br><br> SetHScroll Me, List1, List1.List(0)<br><br>End Sub<br>Add this code, which includes the required API declarations and the SetHScroll routine, to a BAS module. The SetHScroll routine uses the SendMessage API function to send the LB_SETHORIZONTALEXTENT message to a list box. The last argument is an item from the list, preferably one of the longest items. SetHScroll determines the string's width in pixels and passes this value to the list box along with the LB_SETHORIZONTALEXTENT message. The list box sets its horizontal extent to this value, and if it is wider than the list-box control, the list box displays a horizontal scrollbar:<br><br>#If Win32 Then<br><br>Declare Function SendMessage Lib "user32" _<br><br> Alias "SendMessageA" ( _<br><br> ByVal hwnd As Long, ByVal wMsg As Long, _<br><br> ByVal wParam As Long, lParam As Long) As Long<br><br>#Else<br><br>Declare Function SendMessage Lib "user32" _<br><br> Alias "SendMessageA" ( _<br><br> ByVal hwnd As Integer, ByVal wMsg As Integer, _<br><br> ByVal wParam As Integer, lParam As Long) As Long<br><br>#End If<br><br><br><br>'Define constant for message to list-box control<br><br>Const LB_SETHORIZONTALEXTENT = &H194<br><br><br><br>Public Sub SetHScroll(Frm As Form, Ctrl As _<br><br> Control, strText As String)<br><br> Dim nScaleMode As Integer<br><br> Dim nTextWidth As Integer<br><br><br><br> 'Scale in pixels for window message<br><br> nScaleMode = Frm.ScaleMode<br><br> Frm.ScaleMode = 3<br><br> 'Get the width, in pixels, of the text string<br><br> nTextWidth = Frm.TextWidth(strText)<br><br> 'Send a message to the list box<br><br> SendMessage Ctrl.hwnd, _<br><br> LB_SETHORIZONTALEXTENT, nTextWidth, 0<br><br> 'Restore previous scale mode<br><br> Frm.ScaleMode = nScaleMode<br><br>End Sub<br>