7,765
社区成员
发帖
与我相关
我的任务
分享
script_control.ExecuteStatement ("s1=""cool""")
MsgBox script_control.Eval("s1")
'Form1 Module
Option Explicit
Private mScript As New CScript
'---------------------------------------------------------------------------------------
' 过程名 : Command1_Click
' 时间 : 2013-1-28 18:07
' 作者 : 杨过.网狐.cn(csdn bcrun)
' 功能 :
' 说明 :
' 备注 : CSDN之VB一群:283362041
'---------------------------------------------------------------------------------------
'
Private Sub Command1_Click()
On Error GoTo Command1_Click_Error
mScript.WAIT 200
Dim script_control As Object
Dim strLine As String
Dim iLen As Long
Open "26.csq" For Input As #1
iLen = LOF(1)
strLine = StrConv(InputB$(iLen, #1), vbUnicode)
Text1.Text = strLine
Close #1
Set script_control = CreateObject("MSScriptControl.ScriptControl")
script_control.Language = "VBScript"
script_control.AddCode strLine
script_control.AddObject "list", List1
script_control.AddObject "Text", Text1
script_control.AddObject "scrobj", mScript
script_control.Run "main"
On Error GoTo 0
Exit Sub
Command1_Click_Error:
MsgBox "错误 " & Err.Number & " (" & Err.Description & ") in procedure Command1_Click of Form Form1"
End Sub
'CScript ClassModule
Option Explicit
Private Declare Function GetTickCount Lib "kernel32" () As Long
Public Sub WAIT(ByVal msec As Long, Optional blnVar As Boolean = True)
Dim iTick As Long
iTick = GetTickCount
While GetTickCount - iTick < msec And blnVar
DoEvents
Wend
End Sub
'Form1 Module Option Explicit Private mScript As New CScript '--------------------------------------------------------------------------------------- ' 过程名 : Command1_Click ' 时间 : 2013-1-28 18:07 ' 作者 : 杨过.网狐.cn(csdn bcrun) ' 功能 : ' 说明 : ' 备注 : CSDN之VB一群:283362041 '--------------------------------------------------------------------------------------- ' Private Sub Command1_Click() On Error GoTo Command1_Click_Error mScript.WAIT 200 Dim script_control As Object Dim strLine As String Dim iLen As Long Open "26.csq" For Input As #1 iLen = LOF(1) strLine = StrConv(InputB$(iLen, #1), vbUnicode) Text1.Text = strLine Close #1 Set script_control = CreateObject("MSScriptControl.ScriptControl") script_control.Language = "VBScript" script_control.AddCode strLine script_control.AddObject "list", List1 script_control.AddObject "Text", Text1 script_control.AddObject "scrobj", mScript script_control.Run "main" On Error GoTo 0 Exit Sub Command1_Click_Error: MsgBox "错误 " & Err.Number & " (" & Err.Description & ") in procedure Command1_Click of Form Form1"End Sub 'CScript ClassModule Option Explicit Private Declare Function GetTickCount Lib "kernel32" () As LongPublic Sub WAIT(ByVal msec As Long, Optional blnVar As Boolean = True) Dim iTick As Long iTick = GetTickCount While GetTickCount - iTick < msec And blnVar DoEvents Wend End Sub