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?
Printable View
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?
like what?
Example help make the world go 'round.
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
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.
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:
On the lobjScript.Run line, you can ad the parameters.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"
Hope that helps (don't forget to add a reference to the MS Script Control 1.0)
- gaffa