Wrox Programmer Forums
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic 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 May 18th, 2004, 08:43 AM
Authorized User
Join Date: Dec 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default Performing Equations


This is probably a stupid question but it is bothering me.

I am retrieving an equation from a database, the datatype of the column is varchar.

       tmpEq = ((A + E) * 3.141) + C

The equation is then stored in a variable. I then replace the alpha characters with the corresponding numeric values (retrieved from another database table) the variable would then look like this;

      tmpEq = ((cint(10) + cint(10)) * 3.141) + cint(10)

The problem is when I write the tmpEq variable <%=tmpEq%> it writes the string instead of the result of the calculation.

Like I said this is probably a dumb question, but any help would be great.



(Oh this is classic asp and not .net)
Old May 19th, 2004, 04:46 AM
Friend of Wrox
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post

Hi Adam,

If you're using VBScript You could use the Execute method...

Dim result
Execute "result = " & tmpEq
Response.Write result

Or for JScript you could do similar using eval().



Old May 23rd, 2004, 11:54 PM
Friend of Wrox
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41

Sounds a little confusing. I'm sure you have a good reason to store characters you intend to calculate as a varChar, are some of these characters not numbers?
More information would be good:
;;tmpEq = ((A + E) * 3.141) + C
what's A, E and C
;;The problem is when I write the tmpEq variable <%=tmpEq%> it writes the string
what exactly is 'the string'

run some data type functions on your values to determine what they are:
EG if your values A = 2
                    E = 5
are strings A + E = 25 of course if they are numbers will = 7

Wind is your friend

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is this right way for performing a slient install? SatheshKumar .NET Framework 1.x 0 August 4th, 2006 02:56 AM
Variable equations NEO1976 XSLT 3 June 8th, 2006 05:05 PM
Performing an IF test in a DataGrid RichardOrmiston ASP.NET 1.0 and 1.1 Basics 1 December 15th, 2005 11:08 AM
Performing Division in XSLT... Please help.. kiril XSLT 3 May 17th, 2004 05:27 AM
Object or provider is not capable of performing re khalid08 Classic ASP Databases 1 September 22nd, 2003 03:50 AM

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