04-06-2011, 07:25 PM
Hi,
We can't use optional parameter in vbs like we can in VB as follow:
Please provide me an effective solution which will not lead to any major code change!
I am having following option but avoiding because of the "scope" of variable declared for Optional parameter:
Ex.
We can't use optional parameter in vbs like we can in VB as follow:
Code:
InsertRecord "Read"
Public Function InsertRecord(Optional sLogMsg = "Write")
ValidateRecord(sLogMsg )
End Function
Please provide me an effective solution which will not lead to any major code change!
I am having following option but avoiding because of the "scope" of variable declared for Optional parameter:
Ex.
Code:
mymessage = "OPTIONAL" 'sDelimiter = |
Call ABC("asdf", mymessage) 'sDelimiter = | - DEFAULT
Call ABC("asdf", "12345") 'Override Delimiter = '$'
Public Function ABC(str, mymessage) ' OptionaL values in function arguments
If mymessage = "OPTIONAL" Then
mymessage = "123"
End If
Msgbox mymessage
End Function