Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Jun 2002
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    beginner Q: writing efficient VBScript behind form (2002)

    I searched this forum and the VB/VBA forum, but didn't turn anything up that looked relevant. Is there any way to call the same subroutine from several places in a lengthy Item_CustomPropertyChange() function in VBScript behind a custom Outlook form? I've got the same Select Case statement that covers about 8 cases that I need to reuse 3 times. At the moment, that's some 32 lines of code per instance, and I'd hate to repeat it unnecessarily.

    Thanks,

  2. #2
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    Faifax, Virginia, USA
    Posts
    542
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: beginner Q: writing efficient VBScript behind form (2002)

    Abe ~ there is no limit as to how many times a subroutine can be called, nor is there a limit on where it can be called from. In general, you want to move as much of your code to subroutines "as necessary".

  3. #3
    New Lounger
    Join Date
    Jun 2002
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: beginner Q: writing efficient VBScript behind form (2002)

    Thanks, Peter, that's great to know; I've been able to streamline my code somewhat. Should I be declaring my subs at the beginning of my code? I've got a decent amount of experience with programming in CorelScript and a little in VBA, but I heard somewhere that VBScript is a lot less functional than VBA and I'm confused as to what I can and can't do in VBS. Are Declare and Dim OK?

    Abe

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: beginner Q: writing efficient VBScript behind form (2002)

    If you mean Declare as in the kind of Declare used in VB and VBA to access external functions, no, VBS does not support that.

    VBS does not recognize variable types; everything is a variant. Dim var1, var2, var3 is about as complicated as it gets, although it still is good style to use "type" prefixes so you can later figure out what you were trying to do.

Posting Permissions

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