Minggu, 17 September 2017

[MS_AccessPros] Find the longest text in a list box

 

OK VB wizards...


I need to find the longest text in the listbox.


I a finding that ListBx.List is not a vaide property:


The code:


Sub AddHScrollForListBox(ListBx As ListBox)
    Dim i As Integer, intGreatestLen As Integer, lngGreatestWidth As Long
    'Find Longest Text in ListBox
    For i = 0 To ListBx.ListCount - 1
        If Len(ListBx.List(i)) > Len(ListBx.List(intGreatestLen)) Then
            intGreatestLen = i
        End If
    Next i
    'Get Twips
    lngGreatestWidth = ListBx.Parent.TextWidth(ListBx.List(intGreatestLen) + Space(2))
    'Space(1) is used to prevent the last Character from being cut off
    'Convert to Pixels
    lngGreatestWidth = lngGreatestWidth \ Screen.TwipsPerPixelX
    'Use api to add scrollbar
    SendMessage ListBx.hWnd, LB_SETHORIZONTALEXTENT, lngGreatestWidth, 0
End Sub


Any ideas?


Thanks

Art Lorenzini

SD

__._,_.___

Posted by: dbalorenzini@yahoo.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar