473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Converting String Value to a Formula for calculation?

I have come to a situation that I need to use the result of a string
variable as a formula for performing calculation.

As an example below:

Dim X As Integer

Dim Y As Integer

Dim Result As Integer

Dim Formula As String = "X + Y"

X = 3

Y = 5

Result = Formula

MessageBox.Show(Result)

I know that the above example is not working but I am appreciate if someone
out there can help me on that.

I think I have gone through some similar questions inside the newsgroup but
I am not too sure on the solutions. Many thanks to someone out there who is
answering the above question again and if possible, give me an example.

Thank you.
Nov 20 '05 #1
3 5145
Hi SiewSA,

The most used are I think
(1+1).toString that is the same as "2"
Dim myvalue as integer = Cint("2")
Dim myvalue as double = Cdbl("2")

I hope this helps?

Cor
Nov 20 '05 #2
Hi SiewSa,

I see now you want an Eval function, that is not build in.

However you can read here what is written about that in this newsgroup.

http://tinyurl.com/2fznf

Cor
Nov 20 '05 #3
* "SiewSa" <st***********@kerks.com> scripsit:
I have come to a situation that I need to use the result of a string
variable as a formula for performing calculation.

As an example below:

Dim X As Integer

Dim Y As Integer

Dim Result As Integer

Dim Formula As String = "X + Y"

X = 3

Y = 5

Result = Formula

MessageBox.Show(Result)

I know that the above example is not working but I am appreciate if someone
out there can help me on that.

I think I have gone through some similar questions inside the newsgroup but
I am not too sure on the solutions. Many thanks to someone out there who is
answering the above question again and if possible, give me an example.


Samples:

<URL:http://www.codeproject.com/useritems/evaluator.asp>
<URL:http://www.codeproject.com/csharp/livecodedotnet.asp>

MathLib
<URL:http://www.palmbytes.de/content/dotnet/mathlib.htm>

If you have a DevX account:

<URL:http://www.devx.com/codemag/Article/10352/0/page/1/>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Krista Bailie | last post by:
I'm sure this is so easy that it will hurt for anyone to read it, but I really need some direction. I'm trying to create a color chart (RGB) that shows steps between two different colors as...
1
by: Dim | last post by:
Hi, need some help/idea... I have data table in Excel(about 30 columns) and it's getting too big (over 65K) so I need to move it to DB (MS Access is the choice) one of the columns (for example...
5
by: VM | last post by:
If I have a string variable with a formula: string sMyformula = "3.3*5.2*5"; How can I convert this to a mathematical formula that the compiler can calculate? For all purposes, the formula in...
5
by: Masahiro Ito | last post by:
I have column of data that have elapsed time in minutes. For example: 1:15 1:47 23:12 I like to be able to use sql server to do simple math functions. Does anyone have a simple...
9
by: Coleen | last post by:
Hi All :-) I found the way to get my column sum (Thanks Cor I did it a little different, but the result is what I wanted) I used: dt_stat_report_3b.Columns.Add(New DataColumn("Sum",...
4
by: sal | last post by:
Greets, All Converting array formula to work with datatables/dataset tia sal I finally completed a formula I was working on, see working code below. I would like to change this code so it...
3
by: Mike | last post by:
Hi, I have three tables in the following structure (simplified): Table 1: Containing the customers ------------------------------------------------- create table Customers ( int...
116
by: Dilip | last post by:
Recently in our code, I ran into a situation where were stuffing a float inside a double. The precision was extended automatically because of that. To make a long story short, this caused...
30
by: Barry L. Bond | last post by:
Greetings! I just got a new Peet Brothers Ultimeter 2100 Weather Station. This new one has a way to display the heat index, if you press the "dew point" key twice. Being aware of all the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.