i want my program do make commands work from within the running program.. let's say i used command1 and text1 when i write end in text1 and hit command1 i want my program to end when my program is running
Printable View
i want my program do make commands work from within the running program.. let's say i used command1 and text1 when i write end in text1 and hit command1 i want my program to end when my program is running
This thread is marked resolved with no posted resolution.
Did you resolve this issue yourself? If so, please post what you did. Your solution could help others with the same or similiar problem.
Thanks. :)
here this is how i did it, Hack sorry took me forever to find this out haha
First you have to add a component called Microsoft Script Control
and then a a textbox called Text1
and a commandbutton called CmdRun
you can add command buttons if you wantCode:Private Sub Form_Load()
'add the objects you want to use in your script
ScriptControl1.AddObject "form1", Form1
ScriptControl1.AddObject "command1", Command1
Text1.Text = "Sub Form1_Load" & vbcrlf & "form1.backcolor = vbwhite" & vbcrlf & "End Sub"
'Notice when you click on CmdRun it adds the text to the script and load the sub Form1_Load
Private Sub CmdRun_Click()
ScriptControl1.AddCode Text1.Text
ScriptControl1.Run "Form1_Load"
End Sub
add a commandbutton called Command1
Code:Private Sub Form_Load()
'add the objects you want to use in your script
ScriptControl1.AddObject "form1", Form1
ScriptControl1.AddObject "command1", Command1 'Mak sure u add objects(component) you need here!!
Text1.Text = "Sub Form1_Load" & vbcrlf & "form1.backcolor = vbwhite" & vbcrlf & "End Sub"
Text1.Text = Text1.Text & vbcrlf & vbcrlf & "Sub Command1_Click" & vbcrlf & "MsgBox" & " " & chr(34) & "Command 1 CLICKED" & chr(34) & vbcrlf & "command1.left = command1.left + 200" & vbcrlf & "End Sub"
'Notice when you click on CmdRun it adds the text to the script and load the sub Form1_Load
Private Sub CmdRun_Click()
ScriptControl1.AddCode Text1.Text
ScriptControl1.Run "Form1_Load"
End Sub
Private Sub Command1_Click()
On Error Goto ErrHandler
ScriptControl1.Run "Command1_Click" 'This will run the Command1_Click Sub
ErrHandler:
If err.num = 0 then
exit sub
End If
MsgBox "Error Number: " & Err.Number & vbCrLf & "Error Description: " & Err.Description & vbCrLf & "Error Source: " & Err.Source
End Sub