How to pass listbox to sub



I have this sub to resize a listbox:

Sub ResizeListBox()
Dim lineCount As Integer = 0
Dim li As ListItem
For Each li In Me.lstStatus.Items
lineCount += 1
Next li
Me.lstStatus.Rows = lineCount
End Sub

Right now the listbox name is hardcoded. To make it more generic and
reusable, I want to put it in a class and pass any listbox to it.

How do I modify the code to do this?

Thanks much


.



Relevant Pages

  • Re: Listbox selectedindex changed event not firing from within datagrid
    ... the listbox to the command button. ... Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ... >> Although you have added SelectedIndexChanged event handler for ListBox, ...
    (microsoft.public.dotnet.framework.aspnet.datagridcontrol)
  • RE: VBA : how to concatene a list of mails from a form
    ... "PHil" wrote: ... now the button is in the top of the sub form, maybe I should put in the main ... provides your list of students for the lesson. ... The code you have is for a listbox, it loops through and checks which items ...
    (microsoft.public.access.modulesdaovba)
  • Re: Reading a colormap?
    ... " Filter - brings up a filter dialog for the color names", ... # Make a scale for each color component. ... # Make a listbox full of color names. ... sub makeRGBAScales ...
    (comp.lang.perl.tk)
  • RE: Cannot get code to work for API Save Dialog Box
    ... I assume that you are not really naming your listbox listbox. ... Private Sub cmdExportSupportSchedule_Click ... Dim strFilter As String ... Dim varGetFileName as Variant ...
    (microsoft.public.access.forms)
  • RE: Cannot get code to work for API Save Dialog Box
    ... The listbox is called listname so that should not be the problem. ... Private Sub cmdExportSupportSchedule_Click ... Dim strFilter As String ... Dim varGetFileName as Variant ...
    (microsoft.public.access.forms)

Loading