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

Posts: 200
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
 
When You Register, These Ads Go Away!
Old 01-16-2007, 02:52 AM Re: Adding feilds from a DB
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,024
Name: Forrest Croce
Location: Seattle, WA
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.
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
Old 01-16-2007, 07:16 AM Re: Adding feilds from a DB
Zork's Avatar
Extreme Talker

Posts: 200
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

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

vB 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.12106 seconds with 12 queries