如何通过ScriptControl 往listbox添加内容
ScriptControl.AddObject "text", Text1 
可以在text1中添加内容
ScriptControl.AddObject "list", List1
这样没反应,谁知道怎么改

解决方案 »

  1.   

    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完整代码
      

  2.   

     script_control.AddObject "Text", Text1     这句啥意思
      

  3.   

    QQ上交流了下,改了下代码供参考,应该有用:'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 SubCommand1_Click_Error:    MsgBox "错误 " & Err.Number & " (" & Err.Description & ") in procedure Command1_Click of Form Form1"
    End Sub'CScript ClassModule
    Option ExplicitPrivate 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