Passing listbox object as parameter

F

Freddie

hi all,

i have a problem to pass listbox object to a subroutine. i've
successfully pass combo box object so many times, but it displays
error messege 13 "Invalid Data Type messege"

here is the detail:
'*******************************************************************************

Private Sub fillAreaBreakdownLogic()
Select Case cboArea.List(cboArea.ListIndex)
Case constAreaAtmosphere
fillCboBreakdown cboBreakdown,
Worksheet(constSheetRefference).Range("B6:L6"), 0
'the debuger complains here (Type Mismatch),
'the datatypes of the arguments are listbox, range and
integer.
'which are i recon they're the same with the deffinition
'However lstBreakdown's value = Null
fillLstBreakdown lstBreakdown,
Worksheet(constSheetRefference).Range("B6:L6"), 0
End Select
End Sub

Sub fillCboBreakdown(ByRef cbo As ComboBox, ByRef aRange As Range,
Optional ByVal defaultIndex As Integer = -1)
'mind the code... this sub routines has done what i want (filling
combobox
'with items
End Sub

Sub fillLstBreakdown(lst As ListBox, ByRef aRange As Range, Optional
ByVal defaultIndex As Integer = -1)
msgbox "Me" 'when i debug the code, this error messege wasn't even
displayed
End Sub

'*******************************************************************************

freddie
 
D

Dave Peterson

try:

Sub fillLstBreakdown(lst As msforms.ListBox, ByRef aRange As Range, _
Optional ByVal defaultIndex As Integer = -1)

In fact, I think I'd add it to msforms.combobox, too.

There's a listbox on the Forms toolbar and a listbox on the control toolbox
toolbar (ActiveX) and on a userform. So you have to be more specific.

There's an ActiveX (controltoolbox toolbar/Userform) version of the combobox,
but the Forms version is called a DropDown--so the names are unique and you can
be less careful (but I'd still put it in--it's a nice reminder for the other
controls).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top