Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old September 28th, 2005, 12:37 PM
Jaykappy Jaykappy is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 741 Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 9 h 29 m 50 sec
Reputation Power: 22
For Next

I have a bit of code below that is calling another bit of code that is capturing a value and doing some calculations and setting it to a global variable. I then display that calculated value in a message box (see below "Result"). This is in a FOR loop so it repeats 10 times. That works great.

What I want to do next and the reason for this email is to:

1. Each time in run through the loop I want to add the values together.
2. Once I have them I want to divide by 10 to get a mean value.
3. I am looking to get this to run automatically, grabbing 10 values and adding them together.

Does anyone have any hints or examples of how I can add these values together and return one value. Right now I have to hit the message box 10 times. I want this to run automatically and return one number....

THANKS IN ADVANCE

CODE:

Private Sub Command970_Click()

Dim intLoopIndex
Dim Result

For intLoopIndex = 1 To 10

'Total = Ycoord2 + 1
'MsgBox Total

Call Command8_Click

Result = YCoord3 + 1

MsgBox Result

Next intLoopIndex

End Sub

Reply With Quote
  #2  
Old September 28th, 2005, 03:12 PM
Jaykappy Jaykappy is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 741 Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 9 h 29 m 50 sec
Reputation Power: 22
FOR THOSE INTERESTED IN THE ANSWER TO MY QUESTION I FIGURED IT OUT.....

I figured it out. Part of my problem was that some variables were strings, integer, double. I converted them all to Double to retain sig figures.

1. As it goes through the FOR LOOP it adds the values.
2. It then multiplies by .1 (or dividing by 10) For some reason Access wont divide.
3. Finally I place it in a field in my Form

CODE:

Private Sub Command970_Click()

Dim intLoopIndex
Dim Result As Double

For intLoopIndex = 1 To 10

Call Command8_Click

Dim Num
Num = CDbl(YCoord3)

Result = Result + Num ' This will count from 1 to 10 inside the MsgBox

Next intLoopIndex

Result = Result * 0.1

Dim Result2
Result2 = CStr(Result)
Forms!frmAddSign!Y.SetFocus
If Result2 = "" Then
Y.Text = "000.00"
Else
Y.Text = Result2
End If


End Sub

Reply With Quote
  #3  
Old September 28th, 2005, 03:54 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 29 m 58 sec
Reputation Power: 181
Thanks for posting your solution.
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > For Next


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT