Click to See Complete Forum and Search --> : how to evaluate expressions


kanup
February 15th, 2000, 10:51 PM
i got few expressions containing logical "And" ,"Or" .this expressions are in a text file in the following format.
result=((var1And var2)or(var3 And var4)) etc.The expression can be in any number of "and's & or's".
i want to use the VB6.0 logical operators to evaluate my expression.
How will these expression get copied or moved to vb code from the file?
or How will the operators work within a file?

Lothar Haensler
February 16th, 2000, 01:26 AM
you can use the Microsoft Script Control in your VB program.
It has an Eval method that can evaluate any expression that is passed as a string.

kanup
February 17th, 2000, 02:36 AM
sir will u please tell in detail how will u do that.
also please take a note that the string of expressions is in *.txt format

Lothar Haensler
February 17th, 2000, 03:01 AM
here is a sample

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"