(整)通过ScriptControl修改外部数据

通过ScriptControl修改外部数据

Option Explicit

‘ Make a MSScriptControl. (See source for Rod’s
‘ fully commented code. I cut most. Ed.)
Private Sub Form_Load()
Dim script_control As New _
   MSScriptControl.ScriptControl
script_control.Language = "VBScript"
‘这句很关健,要注意
script_control.AddObject "TheForm", Me
script_control.AllowUI = True
‘ Enter the script code.
script_control.AddCode _
   "Sub Main()" & vbCrLf & "   TheForm.BackColor =vbRed" _
    & vbCrLf & "   TheForm.Caption = ""VB6 scripting is easy!""" & _
    vbCrLf & "   TheForm.Width= 5 * 1440" _
    & vbCrLf & "  TheForm.Height =3 * 1440" _
    & vbCrLf & "End Sub"
‘ Execute the Main subroutine.
script_control.Run "Main"

End Sub

Random Posts

Leave a Reply