-
April 24th, 2010, 12:05 PM
#1
visual basic program
hello,
how can we create a vb 6 program to sum 1 to 100 natural numbers
can u tell me the code for this!
thanks
Last edited by annu000sharma; April 24th, 2010 at 10:53 PM.
-
April 24th, 2010, 12:22 PM
#2
Re: visual basic program
Well, probably set up a loop, with an accumulator for the total, and then add the numbers that you want to use, and skip the others
-
April 26th, 2010, 06:21 AM
#3
Re: visual basic program
Definitely a for loop. Natural numbers are all numbers which are not fractional.
Like this:
For i=1 To 100: sum=sum+1: Next
Surely you have to declare the variables and do some work around like using a form and putting a button on and using a textbox to output the value.
Get your hands on, show what you did and you'll sure get more help here.
-
April 26th, 2010, 07:38 AM
#4
Re: visual basic program
Originally Posted by WoF
Definitely a for loop. Natural numbers are all numbers which are not fractional.
Like this:
For i=1 To 100: sum=sum+1: Next
Surely you have to declare the variables and do some work around like using a form and putting a button on and using a textbox to output the value.
Get your hands on, show what you did and you'll sure get more help here.
Shouldn't that be sum=sum+i
Always use [code][/code] tags when posting code.
-
April 26th, 2010, 09:46 AM
#5
Re: visual basic program
Yeah, sorry. Mistyped that. Well spotted, DataMiser.
For i=1 To 100: sum=sum+i: Next
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|