Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 4th, 2004, 09:46 PM
Authorized User
Join Date: Oct 2003
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default Converting a string to an expression

Is it possible to convert a string into an mathematical expression?

For example if I had one string and two integer variables...

dim calculation as string = "a * b"
dim a as integer = 8
dim b as integer = 5

...Is there any way I can use the string variable to calculate a * b?


Old March 5th, 2004, 09:41 PM
planoie's Avatar
Friend of Wrox
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

The .NET languages are strongly typed, meaning that there is no late binding. Well, at least you should not use late binding. This means that you can't do what you want to do in a simple fashion. In JavaScript and VBScript there are "Eval" functions which can basically evaluate anything within the scope of the running code. .NET doesn't support this natively to the best of my knowledge. The article below describes how to compile on the fly.


Work smarter, not harder.

Similar Threads
Thread Thread Starter Forum Replies Last Post
converting node to string mister_mister XSLT 2 January 24th, 2008 12:23 PM
converting a string to regular expression swarnap Javascript How-To 1 November 14th, 2006 04:33 AM
Arithmetic overflow error converting expression to sinapra Classic ASP Databases 8 September 3rd, 2004 12:24 AM
Converting int to string Judex C++ Programming 3 March 1st, 2004 10:44 AM
Arithmetic overflow error converting expression to spikey SQL Server 2000 1 June 24th, 2003 07:19 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.