Results 1 to 3 of 3

Thread: [RESOLVED] commands within running application.. help?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Resolved [RESOLVED] commands within running application.. help?

    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

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [RESOLVED] commands within running application.. help?

    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.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: [RESOLVED] commands within running application.. help?

    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
    Code:
    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
    you can add command buttons if you want
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width