How can I count to 10 while summing the numbers in VBA?
+5
A:
Dim Sum as Integer
Sum = 0
Dim I as Integer
For I = 1 to 10
Sum = Sum + I
Next
Edit: For future reference, please refer to Microsoft's MSDN section on Visual Basic for Applications (VBA)
TheTXI
2009-06-26 17:03:59
Thank you, this was really hard.
Janie
2009-06-26 17:04:43
Dim Sum, LOL ;)
WowtaH
2009-06-26 17:07:09
Hee hee, Lunchtime!!!
Janie
2009-06-26 17:10:08
Mmmmm, dim sum!
gnovice
2009-06-26 17:11:03
+4
A:
The question is labeled VB6, so:
Dim Sum As Integer
Dim i As Integer
For i = 1 To 10
Sum = Sum + i
Next i
Jay Riggs
2009-06-26 17:10:29
@A: if you're really not worried about verbosity, use `theVariableImUsingToCountToTenWith` instead of `i`
Shog9
2009-06-26 17:17:47
I like the anal retentive verbosity advocate who only uses his initial for his first name.
Geoffrey Chetwood
2009-06-26 17:18:58
@Shog9: if you're really not worried about verbosity, use 'iHaveNoIdeaWhetherThisWouldWorkAsAPossibleVariableNameInVBASoIGuessItIsWorthAShotSoIAmCreatingASuperLongVariableNameToHoldSoThatICanWriteAForLoopFromOneToTen'
TheTXI
2009-06-26 17:19:13
A:
Why do you need to use VBA to do this, your using excel, couldn't you just put the numbers 1 to 10 in different cells and add them up. Why do you even need to use excel. Couldn't you just type 1+2+3+4+5+6+7+8+9+10 into a calculator. Why do you even need to use a calculator, why can't you just work it out in your head.
Andrew Marsh
2009-06-26 17:43:49
If I had downvotes left, I'd downvote you just for being extremely late to this party.
TheTXI
2009-06-26 17:45:05
Some of us can't handle two-digit addition in our heads, you insensitive clod.
Pesto
2009-06-26 17:46:31
Um, because i'm trying to LEARN VBA. I'm familiar with calculators, thanks.
Janie
2009-06-26 17:48:12