VB tip - evaluating string expressions (math equations)
For my latest project I needed to be able to evaluate an expression stored in a string. Thought I'd have to write an expression evaluator but found this nifty trick.
Dim Script As New ScriptControl
Dim Formula As String
Dim Result As Double
Script.Language = "VBScript"
Formula = "(sin(4)+5)/2"
Result = Script.Eval(Formula)
You'll need to include a Project Reference for the Microsoft Script Control.
Darrell Spice, Jr. [link|http://www.spiceware.org/cgi-bin/spa.pl?album=./Artistic%20Overpass|Artistic Overpass]\n[link|http://www.spiceware.org/|SpiceWare] - We don't do Windows, it's too much of a chore