Execute a command read from a file?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lance

    #1

    Execute a command read from a file?

    Hi All,

    I would like to read commands from a file and execute them in VB, something
    like reading str = "hello world" into VB and execute it. Any suggestions
    will be appreciated.

    Thanks,
    Lance


  • Raoul Watson

    #2
    Re: Execute a command read from a file?


    "Lance" <Lbrannma@yahoo .com> wrote in message
    news:D6ghe.1374 04$dP1.483869@n ewsc.telia.net. ..[color=blue]
    > Hi All,
    >
    > I would like to read commands from a file and execute them in VB,[/color]
    something[color=blue]
    > like reading str = "hello world" into VB and execute it. Any suggestions
    > will be appreciated.
    >
    > Thanks,
    > Lance
    >[/color]

    Not doable if you want to execute it as you read the file.

    If you want to read the entire file, then yes, you can just write a compiler
    emulator (create variable lists, jump tables, etc.)


    Comment

    • John Smith

      #3
      Re: Execute a command read from a file?

      Like most answers, it depends. I have a program that acts like a server and
      receives commands from a client over the net. The server application then
      executes the commands it receives. My application drives external equipment
      for a whole house audio system.

      So it depends. What are the commands you are trying to execute?

      "Lance" <Lbrannma@yahoo .com> wrote in message
      news:D6ghe.1374 04$dP1.483869@n ewsc.telia.net. ..[color=blue]
      > Hi All,
      >
      > I would like to read commands from a file and execute them in VB,[/color]
      something[color=blue]
      > like reading str = "hello world" into VB and execute it. Any suggestions
      > will be appreciated.
      >
      > Thanks,
      > Lance
      >
      >[/color]


      Comment

      • Steve Gerrard

        #4
        Re: Execute a command read from a file?


        "Lance" <Lbrannma@yahoo .com> wrote in message
        news:D6ghe.1374 04$dP1.483869@n ewsc.telia.net. ..[color=blue]
        > Hi All,
        >
        > I would like to read commands from a file and execute them in VB, something
        > like reading str = "hello world" into VB and execute it. Any suggestions
        > will be appreciated.
        >
        > Thanks,
        > Lance
        >
        >[/color]

        Try out the often overlooked Microsoft Script Control 1.0, available in your
        list of components to add to a project. With a script control called SC1 on a
        form, you can do things like this:

        Private Sub Command1_Click( )
        Dim strCode As String

        strCode = "Sub HelloSub()" & vbNewLine
        strCode = strCode & "strHello = ""Hello World""" & vbNewLine
        strCode = strCode & "Msgbox strHello" & vbNewLine
        strCode = strCode & "End Sub" & vbNewLine

        Debug.Print strCode

        SC1.AddCode strCode
        SC1.Run "HelloSub"

        End Sub




        Comment

        Working...