Script Control
最近有接触到Script Control . 有些问题, 需请教各位.
怎么导入Class Module , 然后怎么样需要进行什么处理后, 可以像VB里自由使用.
[解决办法]
“工程”菜单,“添加类模块”->选择“现存”标签,找到要添加的类模块,打开。
[解决办法]
dim t
set t = new test
call msgbox(t.prop1)
class test
property get prop1()
prop1 = "This is a test."
end property
public sub class_initialize()
end sub
public sub class_terminate()
end sub
end class
Private Sub DoTestScript2()
On Error GoTo DoTestScript2
'On Error GoTo 0
mScript.WAIT 200
Dim script_control As ScriptControl ' Object
Dim sMod26 As String, sMod27 As String
Dim strLine As String
'Text1.Text = strLine
sMod26 = "26"
sMod27 = "27"
Dim vals As Integer
Dim oModule As Module
vals = 4
Set script_control = CreateObject("MSScriptControl.ScriptControl")
script_control.Language = "VBScript"
'script_control.AddCode strLine
Set oModule = script_control.Modules.Add("mdl" & sMod27)
oModule.AddCode ReadTxtFile(App.Path & "" & sMod27 & ".csq")
script_control.AddObject sMod27, oModule
Set oModule = script_control.Modules.Add("mdl" & sMod26)
oModule.AddCode ReadTxtFile(App.Path & "" & sMod26 & ".csq")
script_control.AddObject "list", List1
script_control.AddObject "Text", Text1
script_control.AddObject "scrobj", mScript
'script_control.Run "main"
script_control.Modules(sMod26).Run "main"
'script_control.Modules(sMod27).Run "MSG"
Exit Sub
DoTestScript2:
If Err <> 0 Then
MsgBox "错误 " & Err.Number & " (" & Err.Description & ") in procedure Command1_Click of Form Form1"
End If
End Sub