Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default function and combobox

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default function and combobox

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?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default function and combobox

If you would like to add month names beginning with the next month, would
any ideas here help?

Dim Mth As Long
Dim MthName As String

For Mth = Month(Now) + 1 To Month(Now) + 12
MthName = MonthName(((Mth - 1) Mod 12) + 1)
CreateMonthListBox.AddItem (MthName)
Next Mth

HTH
--
Dana DeLouis
Win XP & Office 2003


"Gixxer_J_97" wrote in message
...
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?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use match function to add different item in Combobox Leonard Lan Excel Worksheet Functions 2 September 9th 09 06:26 PM
ComboBox with an editable function bostonlady Excel Programming 3 February 12th 04 10:33 AM
if it is possible to add a combobox to a self-made function Jean-Paul Viel Excel Programming 1 September 5th 03 07:35 AM
if it is possible to add a combobox to a self-made function . youngman Excel Programming 0 September 4th 03 08:32 AM
Date function and combobox Przemek Wrzesinski Excel Programming 2 July 17th 03 11:41 PM


All times are GMT +1. The time now is 10:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"