T
Travis
strExpression = "1+2+3"
Say I have an expression written in a string. Is there some way that can be
evaluated? Order of precedence does not matter, it should just go from left
to right.
I had an idea using arrays. I figured I could make two arrays, one for the
numbers, one for the operands. It would look at the first two numbers in the
NumberArray, and do the math based on the first operand in the OperandArray.
Then it would take that total, and use it against the third number doing the
math of the next operand, etc. It would work, but I have a problem with this
too. Of what type are operands? My NumberArray is a decimal array. I have no
idea what to make my OperandArray.
So maybe that idea isn't possible. If anyone could help me with either
method that would be great! Either converting a string expression into a
mathematical expression that can be calculated, or how to make an array to
hold *usable* operands.
Thanks!
Say I have an expression written in a string. Is there some way that can be
evaluated? Order of precedence does not matter, it should just go from left
to right.
I had an idea using arrays. I figured I could make two arrays, one for the
numbers, one for the operands. It would look at the first two numbers in the
NumberArray, and do the math based on the first operand in the OperandArray.
Then it would take that total, and use it against the third number doing the
math of the next operand, etc. It would work, but I have a problem with this
too. Of what type are operands? My NumberArray is a decimal array. I have no
idea what to make my OperandArray.
So maybe that idea isn't possible. If anyone could help me with either
method that would be great! Either converting a string expression into a
mathematical expression that can be calculated, or how to make an array to
hold *usable* operands.
Thanks!