C
curiousgeorge408
I want to write the following code:
dim s as variant ' or as string
dim x as double ' or as variant
s = "1+2+3"
x = someFunction(s)
debug.print "-----" & chr(10) & s & chr(10) & x
What is "someFunction"? That is, what VBA function takes a numeric
expression in string form, evaluates it and returns the numerical
result as if I entered the expression directly (e.g. x=1+2+3)?
Obviously, I could do the above by writing the expression in two
places, namely:
s = "1+2+3"
x = 1+2+3
But since I am experimenting with the expression, I would like be able
to modify it in just one place to ensure that "what you see is what
you get" (i.e. I do not make the mistake of modifying only one
instance of the expression).
dim s as variant ' or as string
dim x as double ' or as variant
s = "1+2+3"
x = someFunction(s)
debug.print "-----" & chr(10) & s & chr(10) & x
What is "someFunction"? That is, what VBA function takes a numeric
expression in string form, evaluates it and returns the numerical
result as if I entered the expression directly (e.g. x=1+2+3)?
Obviously, I could do the above by writing the expression in two
places, namely:
s = "1+2+3"
x = 1+2+3
But since I am experimenting with the expression, I would like be able
to modify it in just one place to ensure that "what you see is what
you get" (i.e. I do not make the mistake of modifying only one
instance of the expression).