Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP 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 January 17th, 2005, 09:12 PM
Authorized User
 
Join Date: Aug 2004
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
Default Eval???

hello,

  I have a string like "1, 2, 2, 1"

I want to sum up all the numbers 1+2+2+1=6

How can i do this.

I tried, replace() function to chenge ", " to +
How can i execute this?


------------


 
Old January 17th, 2005, 09:21 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Hi,

Please check the following:

s = "1, 2, 2, 1,30,2,2,5,9,1"
s1 = replace(s,",","+")
sum1 = eval(s1)
response.Write sum1

Hope this helps..

Om Prakash
 
Old January 17th, 2005, 10:02 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
Default

Save a line:

s1 = eval(replace(s,",","+"))

Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
Name "Eval" is not declared. thuyvncr BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 December 21st, 2006 03:48 AM
How to get Object property using EVAL()? srumberg Access VBA 2 November 20th, 2006 06:07 PM
remove eval from code crmpicco Javascript How-To 5 November 30th, 2005 06:51 AM
eval - and other resource hogs crmpicco Javascript 0 September 27th, 2005 06:30 AM
Databinder.Eval jpfree71 ASP.NET 1.0 and 1.1 Basics 2 August 26th, 2004 11:07 AM





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