Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Adding feilds from a DB
Old 01-14-2007, 01:53 AM Adding feilds from a DB
Zork's Avatar
Extreme Talker

Posts: 201
Trades: 0
Hi all!

Here's my situation!
I count my total number using a

For Each Term In Array
count = count + newnumberfromdatabase
Next

But the problem is.. I can't refer to count outside the "For Each" and "Next" operators!! Its stuck it there!! Ah! Get it out..

I can use it it while working inside the for each and next commands just fine.. but unfortunately that's not an option because I want to display the final "count" variable, once.
I'd oh'so appreciate someone's help on this matter!

Thanks
__________________
"Computer games don't affect kids. I mean, if Pacman affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music..."
Zork is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-16-2007, 03:52 AM Re: Adding feilds from a DB
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,023
Name: Forrest Croce
Location: Seattle, WA
Trades: 0
Quote:
Originally Posted by Zork View Post
But the problem is.. I can't refer to count outside the "For Each" and "Next" operators!! Its stuck it there!! Ah! Get it out..

Declare the variable outside the loop. In visual basic you use the dim keyword to do this.

Also, you're probably better off, if this comes from a database, doing a query that selects the sum of your variable ... if your code only loops through the records to total them.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
Old 01-16-2007, 08:16 AM Re: Adding feilds from a DB
Zork's Avatar
Extreme Talker

Posts: 201
Trades: 0
Thanks..declaring the variable outside the loop worked.
Im actually using the ID's from a cookie to call the database and display the selected items in a list with the price to the right.

..Well, actually, I ended up using PayPal's cart, but thanks anyway
__________________
"Computer games don't affect kids. I mean, if Pacman affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music..."
Zork is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Adding feilds from a DB
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.20493 seconds with 12 queries