Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
evaluate a function
I have a function which contains text and numbers which I want t evaluate.
For example, 3*x+3+y I use replace to replace the x with a number, say x = 3, then 3*3+3+y I want the answer to be displayed as 12+y I can't use the & symbol for some resons which I don't want to go through. Is there a way to get the above result without the use of &. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
evaluate a function
Here's one way:
Public Function Test(ByVal x As Integer) As String Dim arr(1) As Variant Dim sResult As String arr(0) = 3 * x + 3 arr(1) = "+ y" sResult = Join(arr) Test = sResult End Function ---- Nick Hebb BreezeTree Software http://www.breezetree.com |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
evaluate a function
Thanks Nick
Your solution works but this is not what I wanted actually I have changeable string with x and y values and I just want the numbers to add up and the texts remains. I don't have a fixed equation. Say I have this equation, 3+ 4*y-3*(5*x-2) I want it to be displayed as 4*y-15*x+9 "Nick Hebb" wrote: Here's one way: Public Function Test(ByVal x As Integer) As String Dim arr(1) As Variant Dim sResult As String arr(0) = 3 * x + 3 arr(1) = "+ y" sResult = Join(arr) Test = sResult End Function ---- Nick Hebb BreezeTree Software http://www.breezetree.com |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
evaluate a function
OK, I gotcha now.
This is a common CS problem often used in data structures classes to teach stacks. You can probably find loads of samples in the internet by searching on the terms "stack calculator" and maybe throw in some terms like "visual basic -.net" and "example" or "sample" to narrow it down a bit. Otherwise, the answer is too long (and time consuming) to figure out and post back here. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Array Function to Evaluate Dates | Excel Worksheet Functions | |||
Evaluate function | Excel Worksheet Functions | |||
Evaluate text string as a function | Excel Discussion (Misc queries) | |||
Using AND function to evaluate cells | Excel Worksheet Functions | |||
EVALUATE Function | New Users to Excel |