Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to Pass Optional Parameters in VBS?
#1
Not Solved Exclamation 
Hi,

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:Sad

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
Reply


Messages In This Thread
how to Pass Optional Parameters in VBS? - by ShrikantBiradar3449 - 04-06-2011, 07:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Pass reference to datatable into function smallsteve 2 1,902 09-28-2017, 09:18 PM
Last Post: smallsteve
  Optional parameter in function amit25007 6 4,948 01-06-2016, 03:29 PM
Last Post: venkatesh9032
  Can you please help me in QTP DP to pass the variable name anshika.agarwal 1 2,601 09-04-2014, 06:43 PM
Last Post: anshika.agarwal
  .vbs script error when trying to insert a value in a sapguitable frebuffi 5 6,496 07-18-2013, 03:04 PM
Last Post: Staff
  optional parameters Ishul 5 7,774 04-03-2012, 11:18 PM
Last Post: supputuri

Forum Jump:


Users browsing this thread: 1 Guest(s)