Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Display Modes
  #1 (permalink)  
Old May 18th, 2004, 08:43 AM
Authorized User
Join Date: Dec 2003
Location: JHB, , South Africa.
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)
  #2 (permalink)  
Old May 19th, 2004, 04:46 AM
Friend of Wrox
Join Date: Jul 2003
Location: , , United Kingdom.
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().



  #3 (permalink)  
Old May 23rd, 2004, 11:54 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
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

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

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 10: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

All times are GMT -4. The time now is 07:09 AM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.