Signature (Visual Basic / VBA)
Public Function InfixToPostfix( _
ByVal vExpr As Variant _
) As Variant
Code Examples
? InfixToPostfix("34 + 45 * 91")
34 45 91 * +
? InfixToPostfix("2 ^ 3 ^ 4 + 5")
2 3 4 ^ ^ 5 +
? InfixToPostfix("A * ( B + C ) + D")
A B C + * D +
? InfixToPostfix("+ A")
A +
? InfixToPostfix("A / B ^ C + D * E - A * C")
A B C ^ / D E * + A C * -
? InfixToPostfix("A + B")
A B +
? InfixToPostfix("A + 0 - B")
A 0 + B -
? InfixToPostfix("A * % ( D + C )")
A * % D C +
? InfixToPostfix("A + B * % G * H")
A B * + G % H *
? InfixToPostfix("% ( D + F ) * 2")
% D F + 2 *
ABS, ASIN, ATAN, COS, LN, SIGN, SIN, SQRT, TAN
^
*, /
\, MOD
+, -
(
Parameters
| Parameter | Description |
|---|---|
| vExpr | String containing the infix-format algebraic expression which will be converted to Postfix. Function returns Null if vExpr is Null or cannot be fixed up to a String. |
Notes & Version History
| Note | This function recognizes the following operators and functions (listed from highest precedence to lowest): The functions at the top of this list have the highest precedence and the open parentheses character has the lowest precedence (and functions/operators on the same line have the same precedence). This function assumes that all other alphanumeric words represent variables or numeric constants. |
| BIG Note | Although this function supports subtraction, it does not support the use of "-" as a unary minus operator. Rephrase any expressions like "-A" into "0-A". |
| Note | This function can also be used to convert from a regular algebraic expression to the format required for entry into a RPN or Reverse Polish Notation calculator. |
| Note | Function will not return an error if the algebraic (infix) expression is ill-formed; it will instead return an ill-formed Postfix expression. |