Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 26, 2010 6:39:54 GMT -5
Hi Guilect,
Can I consign at a 'Sub or Function' an optionale value? When your answer is positiv how are the steps for it? With a negative answer I will burn down my computer! All 'Subs and Functions' will perish in the fire inferno!
But wait! I found a solution for this problem right now. That rescues my old computer and he won't burned down. It is a simple (True/False) method.
Do you have another method for it? Some words about my English: is it understandably?
Best wishes.
|
|
|
Post by Guilect on Jan 27, 2010 21:06:18 GMT -5
VBScript, which B2D uses, does not support an optional parameter to a sub or a function.
The usual work around is to do something like this:
Using the NULL-Checking Approach This technique for optional arguments involves assigning the non-used arguments the value of NULL, then check for the NULL value in the argument. If you have a subroutine, say, MySub, that you wish to allow the user to pass in any of up to three arguments as optional, you should create the subroutine to expect three arguments, like so:
Sub MySub(arg1, arg2, arg3) ... End Sub
Then, to determine whether or not a particular value was passed in, use the IsNull function. For example, if we wanted to determine whether or not the developer had passed in a value for the second argument (arg2), we could do:
If isNull(arg2) Then 'User did not pass in a value for arg2 Else 'The user passed in a value for arg2 End If
To call a function or subroutine that employs this NULL-checking mechanism, simply call the function like normal, passing in NULL for any optional arguments that you wish to omit. For example, to call MySub and not supply the arguments arg1 and arg3, we could call the subroutine like so:
MySub NULL, Value2, NULL
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 28, 2010 10:33:00 GMT -5
Thank you,
|
|