coding parameter constants ?? resolved
Hi intelligent Ones,
This may sound dumb, but I really have no idea. I want to create a function that has constant variable in it. Like the msgbox, where I can either use a 0 or click on the "VBOKOnly" from a drop down menu. I wnat something that will explain a variety of functions. ie 0 means "turn left at the next street", 1 means "Turn left after the next street", and the user would enter other variables, like distances. I am sure this is easy, but an example would help me understand how this works. Also what is the official name for this THING????? don't even know what to search for for help??
Thanks so much. :wave:
Re: coding parameter constants ??
in a bas module declare your constants
like
Public Const TURNLEFT as Integer = 1
or
Public Const TURNLEFT = 1
Public Cont CONSSTRING = "TEST"
etc...
then throught your app
TURNLEFT = 1
if x = TURNLEFT then etc...
;)
Re: coding parameter constants ??
VB Code:
Private Enum eTurns
eTurn_left_at_the_next_street = 0
eTurn_left_after_the_next_street = 1
End Enum
Private Function Whatever(eTurn As eTurns)
End Function
Re: coding parameter constants ??
Therob, I think what you have is close to what I want, Sorry Static, but I do know about constant values. ANyway, I still am a little fussy about how to have the constants and the parameters in the same variable string.
Private Function Whatever(eTurn As eTurns, DistanceLeft as double, distanceRight as double)
End Function
Is that the right way to set up this function. So if the user codes this, will the constant values show up for eTurns automatically ????
Re: coding parameter constants ??
Quote:
Originally Posted by DebbieInFlorida
Is that the right way to set up this function. So if the user codes this, will the constant values show up for eTurns automatically ????
They will indeed. Note that your function does not have a return type...do you mean it to be a subroutine instead? If so:
VB Code:
Private Enum eTurns
Turn_left_at_the_next_street = 0
Turn_left_after_the_next_street = 1
End Enum
Private Sub Whatever(eTurn As eTurns)
End Sub
Re: coding parameter constants ??
Thank you, and I will be returning something, I know how to take care of that. This solved my question, but is there a name for this type of setup???
Thanks again everyone..
Re: coding parameter constants ??
sorry ;) wasnt sure what u were looking for :D
Re: coding parameter constants ??
OK, How do I mark this resolved ???????
Re: coding parameter constants ??
Click edit on your first post and change the title to have [Resolved] at the end - then you can rate everyone that helped :cool:
Re: coding parameter constants ??
THEROB.. actually its easier now!
above the first thread.. click the thread tools link,, pick Mark Resolved!