Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21292

[RESOLVED] AdjustHorizScrollBar in module

$
0
0
Hi,

I am working on a project for other form member and I am receiving a problem with the following

vb Code:
  1. Public Sub AdjustHorizScrollBar(ByRef LB As ListBox, Optional ByVal RightMargin As Long = 4&)
  2.     Dim i As Integer, sngLongestText As Single, TW As Single
  3.  
  4.     With LB
  5.         For i = 0 To .ListCount - 1
  6.             TW = TextWidth(.list(i))
  7.             If sngLongestText < TW Then sngLongestText = TW
  8.         Next
  9.         SendMessageW .hWnd, LB_SETHORIZONTALEXTENT, RightMargin + sngLongestText, 0&
  10.     End With
  11. End Sub

The problem is sub or function not defined.

vb Code:
  1. TextWidth(.list(i))

said forum member asked me to move most the code to a module to declutter the form code.

I call the sub

vb Code:
  1. Private Sub Form_Load()
  2.   load Form1.List1, Form1
  3. End Sub
  4.  
  5. 'In a module
  6. Public Sub load(lst As ListBox, Form As Form)
  7.     AdjustHorizScrollBar lst
  8. End Sub

However, when all the code was in the form the above code worked. What am I missing?

Thanks,


Nightwalker

Viewing all articles
Browse latest Browse all 21292

Trending Articles