VB.NET & Summations

  • Thread starter Thread starter Gopher-216
  • Start date Start date
G

Gopher-216

I'm need the Design source code and the Executable Source code for a
program that does summations Please. Anyone tell me how to in VBScript
make a program/script that when a button is pressed.
 
Gopher-216 said:
I'm need the Design source code and the Executable Source code for a
program that does summations Please. Anyone tell me how to in VBScript
make a program/script that when a button is pressed.

By "summations" you mean?
Possibly allowing entry of multiple data values, then producing some sort of
statistical summary information?

To get useful responses, please be much more specific. For example, what
type of project and a complete description of exactly what you want the
application to accomplish. Fair warning: Unless the project is trivial,
you're unlikely to find anybody here who will develop an entire application
for you, then send it to you for $0.
 
By "summations" you mean?
Possibly allowing entry of multiple data values, then producing some sortof
statistical summary information?

To get useful responses, please be much more specific. For example, what
type of project and a complete description of exactly what you want the
application to accomplish. Fair warning: Unless the project is trivial,
you're unlikely to find anybody here who will develop an entire application
for you, then send it to you for $0.

Summations as in the sum of all natural numbers from n to m.
 
Summations as in the sum of all natural numbers from n to m.


Well, here is code to do the summation. How you get n and m would be the
next question. Just put similar code into your button's click method should
be all you need. I don't understand what "Design source", "Executable
source" and VBScript have to do with this though.

Sub Main()
Console.Write("Enter N and M: ")
Dim input As String = Console.ReadLine()

Dim n As Integer = Integer.Parse(input.Split(" ")(0))
Dim m As Integer = Integer.Parse(input.Split(" ")(1))

Dim sum As Integer = 0
For i As Integer = n To m
sum = sum + i
Next

Console.WriteLine("Sum: " & sum)
Console.ReadLine()
End Sub
 
From the article I referenced:

Sum(a to b)= Sum(1 to b) - Sum(1 to a-1)

=> Sum(a to b)=((b)(b+1)-(a)(a-1))\2

Andrew
 
Back
Top