|
-
February 21st, 2000, 01:23 AM
#1
Reading commands from file
I'm just wondering...
a) is it possible to read input form a file, and them let VB interpret them as actual commands.
Like say a file contain 3 lines, t=t+1, t=t+2, t=t+3.
Is there a way to do this without having to break up the line in small parts and then evaluate them one by one to form the command.
b) is it possible to add a module at run time? Like I have a program that reacts on a specified event with actions defined by the user. These commands are to be placed in a .bas file.
Thanx in advance
Tom Cannaerts
[email protected]
The best way to escape a problem, is to solve it.
-
February 21st, 2000, 02:34 AM
#2
Re: Reading commands from file
all these things can be done by using the "microsoft Script control".
here is my answer to a post from last week about the same thing:
private Sub Command1_Click()
Dim hFile as Integer
hFile = FreeFile
Dim strLine as string
Open "c:\test.txt" for input as #hFile
Do While Not EOF(hFile)
Line input #hFile, strLine
s.ExecuteStatement strLine
Loop
Close (hFile)
End Sub
contents of test.txt
msgbox "hello.world"
msgbox "greetings from the script control"
the script control allows you to add modules, too.
-
February 21st, 2000, 02:46 AM
#3
Re: Reading commands from file
Thanx for the reply, one question however (because I haven't vb around here):
Using the s.ExecuteStatement, can it handle loops (like for, do) and mulptiple-line if-statements?
Tom Cannaerts
[email protected]
The best way to escape a problem, is to solve it.
-
February 21st, 2000, 02:52 AM
#4
Re: Reading commands from file
here is a sample:
private Sub Command1_Click()
Dim c as string
c = "sub test" & vbCrLf & "if a = b then" & vbCrLf & _
"msgbox ""hello, world""" & vbCrLf & _
"end if" & vbCrLf & "end sub"
s.AddCode c
s.ExecuteStatement "a=5" & vbCrLf & "call test"
s.ExecuteStatement "b=5" & vbCrLf & "call test"
End Sub
-
April 9th, 2002, 05:57 AM
#5
A bit of knowledge From Past
;-)
Have a nice day, wherever.
Cesare
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|