Click to See Complete Forum and Search --> : Optional Keyword


Karok
October 5th, 2001, 09:51 PM
Can someone tell me what the default is for a variable that is declared as optional? For example:


Function Fun1(optional byval an_int as Integer)
Fun2(an_int)
End Function


Function Fun2(byval an_int as Integer)
' do something here with an_int
End Function





What will this pseudocode do?


I will rate all useful suggestions :)

In reply to:

A man who asks a question is a fool for 15 minutes. A man who doesn't ask a question is a fool for a lifetime. -Chinese Proverb




Karok

BYaman
October 6th, 2001, 01:12 AM
When you declare a optional parameter. You must set default value such as
Function Fun1(optional byval an_int as Integer=12)
If you don't
parameter value be zero.

ramayansunil
October 6th, 2001, 01:13 AM
Hi,
The syntax for typed optional arguments allows you to specify a default value. If the argument is omitted when the procedure is called, then the argument will have the default value. Here u didnt specify the default value. The default value for the integer when declared will be 0. So it will take it as 0.
If u are declaring the variable as variant then u can use the IsMissing() function to find out whether the procedure is called with the argument or not.
Have a nice day.
sunil.