Article ID: 185889
Article Last Modified on 6/29/2004
Private Sub Command1_Click()
Dim sObjName As String
sObjName = InputBox("Enter the the name for the control " _
& List1.Text, "AddObject Example", List1.Text)
ScriptControl1.AddObject sObjName, Form1.Controls(List1.ListIndex)
MsgBox "Now you can use the keyword """ & sObjName & """" & _
vbCrLf & "to access the properties and methods of " & _
List1.Text & vbCrLf & vbCrLf & "Write some statements " & _
"in the textbox and click on ""Text Script""", vbInformation
End Sub
Private Sub Command2_Click()
ScriptControl1.ExecuteStatement Text1.Text
End Sub
Private Sub Form_Load()
Dim C as Control
For Each c In Form1.Controls
List1.AddItem c.Name
Next
List1.ListIndex = 0
Command1.Caption = "Add the " & vbCrLf & List1.Text & " object" _
& vbCrLf & "for scripting"
Command2.Caption = "Test script"
ScriptControl1.AddObject "ctrls", Form1.Controls
Text1 = "msgbox ""The number of controls is: "" & ctrls.count"
End Sub
Private Sub List1_Click()
Command1.Caption = "Add the " & vbCrLf & List1.Text & " object" _
& vbCrLf & "for scripting"
End Sub
Private Sub Command3_Click()
Dim MyObj As New Class1, bGlobal
bGlobal = MsgBox("The object Myobj is added for scripting. " _
& vbCrLf & "Do you want its members to be global?", _
vbYesNo + vbInformation, "AddObject example")
If bGlobal = vbYes Then
ScriptControl1.AddObject "MyObject", MyObj, True
Else
ScriptControl1.AddObject "MyObject", MyObj, False
End If
MsgBox "Now you can use the keyword ""MyObject"" to access " & _
"all its members" ,vbInformation
End Sub
Public Sub Test()
MsgBox "The is Test method in Class1"
End Sub
184739 INFO: Where to Obtain the Script Control
Additional query words: kbDSupport kbDSD kbScript kbCtrl kbVBp500 kbVBp600 kbVBp
Keywords: kbhowto kbscript KB185889