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
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 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
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 17th, 2005, 08:12 PM
Authorized User
 
Join Date: Aug 2004
Location: , , .
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?


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


Reply With Quote
  #2 (permalink)  
Old January 17th, 2005, 08:21 PM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
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
Reply With Quote
  #3 (permalink)  
Old January 17th, 2005, 09:02 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
Default

Save a line:

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

Wind is your friend
Matt
Reply With Quote
Reply


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
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 02:48 AM
How to get Object property using EVAL()? srumberg Access VBA 2 November 20th, 2006 05:07 PM
remove eval from code crmpicco Javascript How-To 5 November 30th, 2005 05: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



All times are GMT -4. The time now is 02:48 AM.


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