如何进行“包含” VB6中的VBScript的ActiveX对象? [英] how to make an "include" activeX object in vb6 for vbscript?
本文介绍了如何进行“包含” VB6中的VBScript的ActiveX对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这就是我想要做的:
VB6 com.dll,名称和类名:scripting.includefile
sub include(filepath)
ExecuteGlobal(CreateObject("SCRIPTING.FILESYSTEMOBJECT").OPENTEXTFILE("FILENAME, 1).READALL & vbNewLine)
End Sub
vbscript:
set x = createobject("scripting.includefile")
x.include "c:\test.vbs"
call sub_inside_test_vbs
这可能吗?
预先感谢:)
is this possible? thanks in advance :)
推荐答案
如果问题的症结在于将外部脚本文件包含到WSH脚本中,那么您可以简单地停止将脚本编写为裸露的VBS文件,并且
If the crux of the issue here is including external script files into WSH scripts then you can simply stop writing your scripts as naked VBS files and write WSFs instead.
假定这两个文件位于同一文件夹中:
Assume these two files are in the same folder:
Utilities.vbs (这里我们仅将一个Sub定义为演示)
Utilities.vbs (Here we'll just have one Sub defined as a demo)
Option Explicit
Private Sub BubbleSort(ByRef ArrArrs, ByVal SortBy, ByVal Descending)
'ArrArrs is an array of arrays to sort.
'SortBy is the index of the element in each subarray
' to sort by.
'Descending is a Boolean value.
Dim FirstX
Dim LastSwapX
Dim LastX
Dim X
Dim Temp
FirstX = LBound(ArrArrs)
LastSwapX = UBound(ArrArrs)
Do
LastX = LastSwapX - 1
LastSwapX = 0
For X = FirstX To LastX
Temp = ArrArrs(X)
If (Temp(SortBy) > ArrArrs(X + 1)(SortBy)) Xor Descending Then
ArrArrs(X) = ArrArrs(X + 1)
ArrArrs(X + 1) = Temp
LastSwapX = X
End If
Next
Loop While LastSwapX
End Sub
DemoScript.wsf
<job>
<script language="VBScript" src="Utilities.vbs"/>
<script language="VBScript">
Option Explicit
Private AA
Private I
Private Msg
AA = Array(Array("Joe", "Rockhead", "56 Boulder Street"), _
Array("Barney", "Rubble", "125 Rockaway Lane"), _
Array("Fred", "Flintstone", "123 Rockaway Lane") _
)
BubbleSort AA, 1, False
Msg = vbNullString
For I = LBound(AA) To UBound(AA)
Msg = Msg & Join(AA(I), ", ") & vbNewLine
Next
WScript.Echo Msg
</script>
</job>
这篇关于如何进行“包含” VB6中的VBScript的ActiveX对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文