Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass ComboBox object to a function 1

Status
Not open for further replies.

Strobeman

Programmer
May 16, 2003
40
AU
In Microsoft's help for adding an item to a ComboBox they show an example(see below) where you pass the ComboBox as an object to a function. Unfortunately they do not show the code calling this function and when I try and do it I get an error. Has anybody managed to do this?


This example adds an item to the beginning of the list in a combo box control. For the function to work, you must pass it a ComboBox object representing a combo box control on a form and a String value representing the text of the item to be added.

Function AddItemToBeginning(ctrlComboBox As ComboBox, _
ByVal strItem As String)

ctrlComboBox.AddItem Item:=strItem, Index:=0

End Function
 
when I try and do it I get an error
Which error with which code ?

Call example:
AddItemToBeginning Me!myCombo, "New text"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV. I have been coding in C# for a while now and was trying to call the function with the parameters in brackets. This works like a dream now.
 
Or:

Call AddItemToBeginning(Me!myCombo, "New text")

Max Hugen
Australia
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top