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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Imbed cbo in function parameters? 1

Status
Not open for further replies.

DbHd

Programmer
Dec 20, 2004
39
In some built-in functions like msgbox you can pick parameters from a combo. Eg., msgbox "Prompt", [Buttons as VBMessageBoxStyle] cbo opens here and you select vbConstants from drop down list.

How can I include a combo in my functions?
 
Are you trying to simply send parameters to your function?

If so then

public function WhatToSay (stRec as string, iNum as integer) as string

whattosay = "You wanted me to say " & strec & " " & inum & " time/s."
end function

The call would be someting like

Dim stWhat as string
msgbox WhatToSay("Hello",4) As you type in the "WhatToSay" portion here you will be prompted for you inputs.

The result of the line above would be

"YOu wanted me to say Hello 4 time/s"

The bold part in my function here is only for readability, this is the parameter part of your function.

Hope that helps, but with so little information to go on in your original question I think I have given you what you need.

Holler back if I have over-simplified or missed the mark all together.

Thanks





Andy Baldwin

"Testing is the most overlooked programming language on the books!
 
How are ya DbHd . . .

I believe your talking enumeration here, as such you can use the [blue]Enum[/blue] statement. Just [blue]note that enum is a list of names representing numeric constants.[/blue] Its is these names you see in the list as you enter parameters in routines.

As an example, in the declaration of a new module in the modules window, copy/paste the following:
Code:
[blue]Enum MyColor
   mcBlack = 0
   mcWhite = 16777215
   mcRed = 128
   mcLtRed = 15790335
   mcBlue = 8388608
   mcLtBlue = 16773360
   mcGreen = 16384
   mcLtGreen = 15925234
   mcPurple = 9044037
   mcLtPurple = 16771828
   mcBrown = 16512
   mcLtYellow = 15269887
   mcLtGray = 12632256
   mcDrkGray = 8421504
End Enum[/blue]
That done, now when you design a new routine and prescribe parameters you set the type name above for those parameters of interest:
Code:
[blue]Public Sub SetColor(ID as Long, ForeColor As [purple][b]MyColor[/b][/purple], BackColor As [purple][b]MyColor[/b][/purple])
   [green]'Code[/green]
End Sub[/blue]
Now when you call the routine in code you'll get those listings to choose from . . .

[blue]Your thoughts?[/blue]

Calvin.gif
See Ya! . . . . . .
 
You're spot on Ace! I looked at everything I could think of but missed that one. You get a star!

Thanks!

Db
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top