|
-
Oct 6th, 2000, 03:15 PM
#1
Thread Starter
New Member
HI there,
I have a function in VB which has 2 optional parameters. How can I find out whether the parameter was set or not.
Regards,
Radhika
-
Oct 6th, 2000, 03:17 PM
#2
Fanatic Member
Use the IsMissing Function:
Dim ReturnValue
' The following statements call the user-defined function procedure.
ReturnValue = ReturnTwice() ' Returns Null.
ReturnValue = ReturnTwice(2) ' Returns 4.
' Function procedure definition.
Function ReturnTwice(Optional A)
If IsMissing(A) Then
' If argument is missing, return a Null.
ReturnTwice = Null
Else
' If argument is present, return twice the value.
ReturnTwice = A * 2
End If
End Function
Crispin
VB6 ENT SP5
VB.NET
W2K ADV SVR SP3
WWW.BLOCKSOFT.CO.UK
[Microsoft Basic: 1976-2001, RIP]
-
Oct 6th, 2000, 03:22 PM
#3
The following example demonstrates how you can set a default value for an argument. For example, if nothing is entered in Param2, then it will be 12.
Code:
Function MyFunc(ByVal Param1 As Long, Optional ByVal Param2 As Long = 12) As Long
End Function
-
Oct 6th, 2000, 04:02 PM
#4
Thread Starter
New Member
Thanks
Thanks it worked.
Radhika
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|