7,763
社区成员
发帖
与我相关
我的任务
分享
'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
Private Sub Command1_Click()
Dim script_control As Object
Open "C:\262626\26.csq" For Input As #1
L = LOF(1)
strline = StrConv(InputB$(L, #1), vbUnicode)
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.Run "main"
End Sub
完整代码