Results 1 to 5 of 5

Thread: Code from text file

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    Las Vegas, Nevada, USA
    Posts
    4

    Question

    Is thier a way to get some Visual Basic code from a text file and 'play' it?

    CyberWil

    P.S. If so, can someone make me a VB project file?

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,092
    like what?
    Example help make the world go 'round.

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    Las Vegas, Nevada, USA
    Posts
    4

    Post Re: code from text file

    Like:

    This in text file:

    Msgbox "Test"
    End

    Then i say in VB:

    Open "test.txt" for input as #1
    Play Code Here
    Close #1

    CyberWil

  4. #4
    Guest
    I understand what you mean. What you mean is that you put:
    Msgbox "Hello"
    in a text file. And you want to load it and have VB say:
    Msgbox "Hello"
    from the file. I don't think this can be done though.

  5. #5
    Guest
    You can use the script control to do this, but you need to add the procedures and modules properly. MSDN has reasonable resources on this.

    Basically, the code would look like this:

    Code:
        Dim lobjScript As ScriptControl
        Dim lstrParams As String
        
        'Init the scripting object
        Set lobjScript = New ScriptControl
        'Setup the language
        lobjScript.Language = "VBScript"
        lobjScript.Reset
        
    
        lobjScript.AddCode "Your code goes here"
        lobjScript.Modules.Add "TestSub" 'so yo can reference it later
        'Execute the code
        lobjScript.Run "TestSub"
    On the lobjScript.Run line, you can ad the parameters.

    Hope that helps (don't forget to add a reference to the MS Script Control 1.0)

    - gaffa

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