g-man
Thu Jul 13 21:33:26 CDT 2006
You will need to add error checking as necesary...
**************************************************************************************************
FirstNumber = inputbox("First Number")
SecondNumber = inputbox("Second Number")
For MyIncrement = FirstNumber to SecondNumber
MyCount = MyCount + MyIncrement
Next
Wscript.Echo "The Sum of all numbers between " & FirstNumber & " and "
& SecondNumber & " is: " & MyCount
**************************************************************************************************
Richard Mueller wrote:
> Big_Blue wrote:
>
> > How do I return the sum of all integers from two text boxes. If the end
> > user inputs 5 in the first textbox and then 10 in the second textbox my
> > answer needs to be 45.
> > 5+ 6+7+8+9+10=45? I am using VB.NET 2003
>
> Hi,
>
> A function similar to below should work:
> ===============
> Private Function SumIntegers(ByVal intStart As Integer, ByVal intEnd As
> Integer) As Integer
> Dim k As Integer
> SumIntegers = 0
> For k = intStart To intEnd
> SumIntegers = SumIntegers + k
> Next
> End Function
> ==============
> The function returns 0 if intStart is larger than intEnd. Pass the Text
> properties of the textboxes to the function.
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab -
http://www.rlmueller.net