RE: function and combobox

From: Gixxer_J_97 (GixxerJ97_at_discussions.microsoft.com)
Date: 02/11/05


Date: Fri, 11 Feb 2005 13:57:06 -0800

fixed it -

> <BEGIN VB CODE>
> Private Sub CreateMonthListBox(MonthListBox as ComboBox)
>
> MonthListBox.AddItem ("March")
> MonthListBox.AddItem ("April")
> MonthListBox.AddItem ("May")
> MonthListBox.AddItem ("June")
> MonthListBox.AddItem ("July")
> MonthListBox.AddItem ("August")
> MonthListBox.AddItem ("September")
> MonthListBox.AddItem ("October")
> MonthListBox.AddItem ("November")
> MonthListBox.AddItem ("December")
> MonthListBox.AddItem ("January")
> MonthListBox.AddItem ("February")
>
> End Function
> <END VB CODE>

and using Call CreateMonthListBox()

works fine now

"Gixxer_J_97" wrote:

> Hi all
>
> I am trying to create a function that will take a combo box as an argument
> and additem the names of the months to it. the reason for the function is
> that i will be using several combo boxes throughout my form with the same data
>
> so far my code is as follows:
>
> <BEGIN VB CODE>
> Private Function CreateMonthListBox(MonthListBox&) As ComboBox
>
> CreateMonthListBox.AddItem ("March")
> CreateMonthListBox.AddItem ("April")
> CreateMonthListBox.AddItem ("May")
> CreateMonthListBox.AddItem ("June")
> CreateMonthListBox.AddItem ("July")
> CreateMonthListBox.AddItem ("August")
> CreateMonthListBox.AddItem ("September")
> CreateMonthListBox.AddItem ("October")
> CreateMonthListBox.AddItem ("November")
> CreateMonthListBox.AddItem ("December")
> CreateMonthListBox.AddItem ("January")
> CreateMonthListBox.AddItem ("February")
>
> Set MonthListBox = CreateMonthListBox
> End Function
> <END VB CODE>
>
> the line that calls this function is:
>
> CreateMonthListBox (depositMonthList)
>
> depositMonthList is a ComboBox on my form
> when i run my code i get the error:
>
> Run-time error'13'
> Type mismatch
>
> ??? - what am i doing wrong?



Relevant Pages

  • Re: function and combobox
    ... Dana DeLouis ... >> Private Sub CreateMonthListBox ... > and using Call CreateMonthListBox() ... >> Private Function CreateMonthListBoxAs ComboBox ...
    (microsoft.public.excel.programming)
  • Re: Problem Using Delete Key Because of Combobox
    ... Private Sub ComboBox1_Change ... Dim myCell As Range ... The list and the combobox are both in the same sheet. ... I want it to populate whichever cell I ...
    (microsoft.public.excel.misc)
  • Re: RE: User Forms
    ... Both the listbox and combobox are set to display the ... Private Sub FillCboBox ... Dim SrcData As Range ... For Each cCell In SrcData.Cells ...
    (microsoft.public.excel.newusers)
  • Re: Returning an Auto Text from a Combo Box
    ... Save that document somewhere and modify this line of code in the Private Sub ... the name of ComboBox1, when the userform is displayed, that combobox will be ... Set addressRange = Selection.Range ... ' Open the file containing the client details ...
    (microsoft.public.word.vba.general)
  • Re: Returning an Auto Text from a Combo Box
    ... Save that document somewhere and modify this line of code in the Private Sub ... the name of ComboBox1, when the userform is displayed, that combobox will be ... Set addressRange = Selection.Range ... ' Open the file containing the client details ...
    (microsoft.public.word.vba.general)

Loading