473,406 Members | 2,387 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,406 software developers and data experts.

Performing Calculations From a Text string

If I have a string, "(5+3)/8" or "23>9"
Has .NET provides some sort of parser that can get me the mathematical answer?

Years ago, in VB6 I found an answer to this question using some sort of
web-based object. It's been so long, I forget even what it was.

--
--Zorpie
Nov 21 '05 #1
2 1155
I found my own answer if no one else has one. I use a Datatable to do the
computation for me:

Sub Main()
Dim B As Boolean = False
B = CBool(Compute("7=7", B.GetType))
Dim N As Decimal = 0
N = CDec(Compute("8+3.4", N.GetType))
Dim S As String = String.Empty
S = CStr(Compute("'Me ' + 'You'", S.GetType))
MsgBox(B.ToString + vbCrLf + N.ToString + vbCrLf + S)
End Sub

Private Function Compute(ByVal S As String, ByVal ResultType As Type) As
Object
Dim DT As New DataTable
DT.Columns.Add(New DataColumn("A", ResultType))
DT.Rows.Add(DT.NewRow)
DT.Columns("A").Expression = S
Return DT.Rows(0)("A")
End Function

--
--Zorpie
"Zorpiedoman" wrote:
If I have a string, "(5+3)/8" or "23>9"
Has .NET provides some sort of parser that can get me the mathematical answer?

Years ago, in VB6 I found an answer to this question using some sort of
web-based object. It's been so long, I forget even what it was.

--
--Zorpie

Nov 21 '05 #2
"Zorpiedoman" <no*********@beatles.com> schrieb:
If I have a string, "(5+3)/8" or "23>9"
Has .NET provides some sort of parser that can get me the mathematical
answer?

Years ago, in VB6 I found an answer to this question using some sort of
web-based object. It's been so long, I forget even what it was.


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

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

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

Similar topics

3
by: special_agent69 | last post by:
Not sure if this is a stoopid question or not. If it is, my apologies. I'd like to have an ASP form performing a relatively simple calculation. For example, if I wanted to create a simple...
2
by: Scot Niklos via AccessMonster.com | last post by:
Sorry if it is way to much information but I'm trying to cover all bases Access 97 A= combobox that queries Distributor B= combobox that limits customers by distributor in a C= combobox that...
2
by: Jeronimo Bertran | last post by:
I have an aspx page that shows a complex image with several objects that are sensitive to mouseover events. The information about the objects in the image is obtained from a database and complex...
8
by: Charlie Brookhart | last post by:
I am creating a program that involves having to find the difference between two dates and converting it to a number to be used for calculations. The problem is that the way it is setup, VB is not...
2
by: Mike P | last post by:
Is it possible to perform calculations on data in your gridview in your ASP, or do you need to do any calculations in the OnRowDataBound event? Here is what I am trying to do : ...
22
by: robertmeyer1 | last post by:
Hi. I have been working on creating the structure of a DB and now I am trying to create some queries which will perform calculations. I have 1 table, tblAnswers which is based off an append query....
22
by: Rickster66 | last post by:
As Instructed this is a new thread regarding my original post: "Select Only 10 Columns Going Back" I'm sorry for the late response. I've been gathering up information and carefully with as much...
8
by: Sham | last post by:
I am trying to perform the following query on a table that has been indexed using Full Text Search. The table contains multiple columns than have been indexed. (Below, all xml columns are...
9
Catalyst159
by: Catalyst159 | last post by:
I have a form which is used to calculate residential Floor Area Ratio (FAR). The form is structured into seven parts as follows: Part A: Maximum FAR and Floor Area: Part B: Gross Floor Area of...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.