|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
OK Needs ome help here, I have been tryign and trying and trying. and Can not get it. I have 7 text boxes and 1 total box (see attachment (course I have stripped alot of my code out of it)) txtscore1 txtscore2 txtscore3 txtscore4 txtscore5 txtscore6 txtscore7 txttotal Heres what I am trying to do. if I put 100 in txtscore1 and 200 in txtscore2 I want them to add together in txttotal showing 300, then if i put 100 in txtscore3 it adds that to what ever is in txttotal already showing 400, basically to keep a running total. Thank You for your Help Lord_Night |
|
#2
|
|||
|
|||
|
Your problem is quite simple.
You had the right idea in creating a control array from your textboxes, however, you did not execute it correctly. The first column of textboxes you have named txtScore1, txtScore2, etc. The problem here is that each of these you have set as a different control array. What I did was I named all the textboxes in the first column of to txtScore1. This creates a control array ( first txtScore1 has an array index of 0, the next gets 1, and so on ). I did the same for the second column, however, I named those txtScore2 respectively. This makes your code a lot more manageable. Now I wrote the code to loop and calculate the values on the fly. Here is the code in full... much shorter than what you had. This code is everything in FrmScorer : Code:
Option Explicit
Private Sub txtTotal_calculation()
Dim total As Double
Dim i As Integer
total = 0
For i = 0 To txtScore1.UBound Step 1
total = total + Val(txtScore1(i).Text)
Next i
txtTotal1.Text = total
End Sub
Private Sub txtScore1_Change(Index As Integer)
Call txtTotal_calculation
End Sub
BTW, I deleted your about form event as you did not include the frmAbout form.
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. |
|
#3
|
|||
|
|||
|
Thank You So much laidbak, I overlooked a few things,
worked great even got the second row adding. Thanks Again for showing the easy one....... Lord_Night ![]() |
|
#4
|
|||
|
|||
|
No problem. We all have times when we overlook the most (seemingly) obvious items.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > adding Numbers in text boxes....Please Help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|