Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Array Function to Evaluate Dates LarryP Excel Worksheet Functions 6 April 15th 08 02:58 PM
Evaluate function Stefi Excel Worksheet Functions 7 November 21st 07 12:50 PM
Evaluate text string as a function benb Excel Discussion (Misc queries) 3 July 19th 06 02:41 PM
Using AND function to evaluate cells murphyslaw18 Excel Worksheet Functions 1 January 13th 06 12:38 AM
EVALUATE Function Frank H. New Users to Excel 4 January 6th 05 02:34 AM


All times are GMT +1. The time now is 07:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"