Solve Linear Equation
Here is a small VBA code to get the result of an equation which have one variable. In the procedure the GetEquationResult is called with arguments with the equation as string, variable as string and variable value as number.
If the equation is (x-5)*(x-2) and x=10 then on running TestMe procedure will pop up a msgbox with value 40.
Sub TestMe() MsgBox GetEquationResult("(x-5)*(x-2)", "x", 10) End Sub Function GetEquationResult(sEquation As String, sVariableName As String, dblVariableValue As Double) As Double GetEquationResult = Evaluate(Replace(sEquation, sVariableName, dblVariableValue)) End Function
»
- Vishesh's blog
- Login or register to post comments
- 7034 reads
Incorrect Understanding of the Nomenclature
How is that an equation? An equation has two equated sides.
This is just a polynomial of First Degree!
Thanks Vaibhav for correcting
Thanks Vaibhav for correcting me. I would request you to please suggest a suitable title for this blog entry.
Title
"evaluating a polynomial of first degree"- springs to mind.