answersLogoWhite

0


Best Answer

//Script by aakash30jan

<script type="text/vbscript">

For count = 1 to 10

sum=sum+count

document.write("<br />" & sum)

Next

</script>

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

9y ago

The sum of the first n natural numbers is a recursive function such that f(n) is f(n-1)+n for all values n >1 where f(1) is 1. Although the function is naturally recursive, an iterative implementation would prove more efficient:

Function sum_naturals(ByVal num As UInteger) As UInteger

sum_naturals = 0

While (num > 0)

sum_naturals = sum_naturals + num

num = num - 1

End While

End Function

Sub Main()

Console.Write("The sum of all naturals 1 to 42 is: ")

Console.WriteLine(sum_naturals(42))

End Sub

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

You never specified what do you mean by 'n' numbers.

to get a sum of two numbers, assign both to value

(ex: dim num1 as integer = textbox1.text

dim num2 as integer = textbox2.text )

or another example:

dim num1 as integer = 2398

dim num2 as integer = 2989

now write:

label1.text = num1 + num2

for the output (answer) to appear on label1

to make it appear in a msgbox do

msgbox(num1 + num2)

or

dim num3 as integer = num1 + num2

msgbox(num3)

and for a more good looking way:

msgbox( "the answer is: " & num3)

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: A program to find the sum of n numbers in visual basic?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Program to print all the even numbers of an array in visual basic?

find even number in array


Where can you find basic tutorials showing how to make a virus?

There are many online sites where and individual can find basic tutorial showing how to make a virus. There are tutorials on HackTweaks and Youtube that show how to make a virus with the program Visual Basic.


Where can you find information on Visual Basic coding?

One place to find information on visual basic coding is a local library. The website msdn microsoft has extensive tutorials and guides on visual basic coding.


Where do you find the applications such as visual basic or visual C plus plus in visual studio 2010 there appears to be no actual applications?

Once you have the Visual Studio program open, go to File-&gt;New Project and select the language you want to write your program in. If one or more languages do not appear, you probably didn't choose to have them installed when you installed Visual Studio.


How do you write a program to find out the square and cube of first ten natural numbers in gw basic?

First you will need to have some basic programming knowledge. You can use this to help make the program that is needed.


Where can you find Microsoft visual foxpro program codes?

bwiset


Where can one find a tutorial for Visual Basic?

Tutorials for Visual Basic can be found on MSDN Microsoft, Amos Development, and Home and Learn UK. The Engineering Department at Auburn University also offers a very detailed tutorial for Visual Basic.


How do you write a program in Basic to display all the even numbers up to 100?

In visual basic: Module Module1 Sub Main() Dim Inst As Integer For Inst = 0 To 100 Step 2 Console.WriteLine(Inst) Next End Sub End Module


Where can you find starting out with visual basic 2010 solutions?

cheggcom has a great group to answer


I wrote a Visual Basic program a few years back but I have lost the programming code Is there any way to open my program and still have the program in Visual Studio?

- If you mean to get the code from an exe file ... well, that is illegal. - Its not illegal if you created the code in the first place ... So an answer can not be given here. If you find some way to get the source out of the exe and THEN prove that you own it then every thing should be OK.


How to write a C program to find largest 2 numbers using pointers?

program to find maximum of two numbers using pointers


How do you write a VBnet program to find the prime numbers between 100 to 200?

VBnet program to find the prime numbers between 100 to 200?