optional subroutine parameters

Results 1 to 2 of 2

Thread: optional subroutine parameters

  1. #1
    Join Date
    Dec 1969

    Default optional subroutine parameters

    Is it possible to use optional subroutine parameters in VBScript? Not a problem in VBA, but not working in VBScript<BR>ie. sub mysub(optional myvar)

  2. #2
    BillW@chilisoft.com Guest

    Default RE: optional subroutine parameters

    No. Period.<BR><BR>But see www.learnasp.com for a way that Charles Carroll (I think)<BR>dreamed up that uses a Dictionary object to pass the parameters.<BR><BR>Simply put, the caller does <BR> Set parms = Server.CreateObject("Scripting.Dictionary")<BR> parms.Add "filename","c:fooey.txt"<BR> parms.Add "user","John Doe"<BR> Call someProc( parms )<BR><BR>and then in the function/procedure code you do<BR> Proc someProc( args )<BR> If args.Exists("filename") Then<BR> fname = args("filename")<BR> Else<BR> fname = "c:defaultpath
    ame.txt"<BR> End If<BR> If args.Exists("email") Then<BR> email = args("email") <BR> Else<BR> email = "homer@simpson.org"<BR> End If<BR> ... etc.<BR><BR>Ugly, clumsy, slow...but it works when nothing else will.<BR><BR><BR><BR> email = args("email"<BR> <BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts