How to get variables from another vbscript (another .vbs file)

vbscript

Solution

For .HTA/.HTML/.WSF don't try to re-invent the wheel but use the src attribute of the script tag.

For plain .VBS use ExecuteGlobal as demonstrated here:

Dim gsLibDir : gsLibDir = "M:\lib\kurs0705\"
Dim goFS     : Set goFS = CreateObject( "Scripting.FileSystemObject" )
ExecuteGlobal goFS.OpenTextFile( gsLibDir & "BaseLib.vbs" ).ReadAll()

In either case put the code to be re-used into the included file; don't waste work on fancy Include Subs/Functions that provide nothing more than a one-liner.

Problem

I have a file which has following variables. ``` Dim apple(10) apple(0)= "banana" apple(1)= "2 banana" apple(2)= "3 banana" ``` and these variables are in `script/test/test.vbs` Now i have another file which has following ``` MSGBOX apple(0) MSGBOX apple(1) ``` which is in `script/main.vbs` how to make these possible?

Original source