How to include a .vbs file in other .vbs file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • trongnguyen
    New Member
    • Feb 2008
    • 1

    How to include a .vbs file in other .vbs file

    Hi all,
    I have 2 .vbs files (a.vbs and b.vbs).
    -------------------------------------------------------
    Content of a.vbs file:
    Option Explicit
    Public Sub A()
    End Sub
    --------------------------------------------------------
    I want to call Sub A() of a.vbs in b.vbs (include a.vbs in b.vbs)
    How to achieve this?
    Thanks so much!
  • CroCrew
    Recognized Expert Contributor
    • Jan 2008
    • 564

    #2
    If you’re trying to include a file in an ASP file the syntax is:

    <!--#include file="FilePathA ndName"-->
    Or
    <!--#include virtual=" FilePathAndName "-->

    The differentness between the two keywords is when using the virtual keyword you indicate a path beginning with a virtual directory but, when using the file keyword you indicate the relative path from the calling file.

    You can add as many includes as you need. Now for the fun part, if you want one function to be called from another include then make sure that include file is listed first.

    Example page that is called FileC.asp:
    <!--#include file="FileA.asp "-->
    <!--#include file="FileB.asp "-->
    There is a Function that is located in FileA.asp that needs to be called from a Function in FileB.asp that was originally triggered by a Sub in FileC.asp

    I told you that was the fun part..

    I hope that I explained it clearly for an ASP include~

    Comment

    • markrawlingson
      Recognized Expert Contributor
      • Aug 2007
      • 346

      #3
      Are you actually using VB6, not ASP? If so you've posted in the wrong forum, we can't help you out there. Let me know and I will move this thread to the Visual Basic forum.

      Sincerely,
      Mark

      Originally posted by CroCrew
      If you’re trying to include a file in an ASP file the syntax is:

      <!--#include file="FilePathA ndName"-->
      Or
      <!--#include virtual=" FilePathAndName "-->

      The differentness between the two keywords is when using the virtual keyword you indicate a path beginning with a virtual directory but, when using the file keyword you indicate the relative path from the calling file.

      You can add as many includes as you need. Now for the fun part, if you want one function to be called from another include then make sure that include file is listed first.

      Example page that is called FileC.asp:
      <!--#include file="FileA.asp "-->
      <!--#include file="FileB.asp "-->
      There is a Function that is located in FileA.asp that needs to be called from a Function in FileB.asp that was originally triggered by a Sub in FileC.asp

      I told you that was the fun part..

      I hope that I explained it clearly for an ASP include~

      Comment

      • CroCrew
        Recognized Expert Contributor
        • Jan 2008
        • 564

        #4
        trongnguyen was asking not me </grin>. But I do think he was asking a VB6 question and I turned it into an ASP one.

        Sorry~

        Comment

        • markrawlingson
          Recognized Expert Contributor
          • Aug 2007
          • 346

          #5
          No need to apologize :) Just want to get the post to the right area.

          Sincerely,
          Mark

          Originally posted by CroCrew
          trongnguyen was asking not me </grin>. But I do think he was asking a VB6 question and I turned it into an ASP one.

          Sorry~

          Comment

          Working...