don't calculate the lowest number
don't calculate the lowest number
don't calculate the lowest number
don't calculate the lowest number
don't calculate the lowest number
don't calculate the lowest number don't calculate the lowest number don't calculate the lowest number don't calculate the lowest number don't calculate the lowest number don't calculate the lowest number don't calculate the lowest number don't calculate the lowest number
don't calculate the lowest number don't calculate the lowest number
don't calculate the lowest number
Go Back  Xtreme Visual Basic Talk > > > don't calculate the lowest number


Reply
 
Thread Tools Display Modes
  #1  
Old 06-21-2010, 05:55 AM
ary ary is offline
Newcomer
 
Join Date: Jun 2010
Posts: 1
Default don't calculate the lowest number


I have a form that has 6 boxes that the user enters the number then adds them all up

but what i want is to only add the highest number the user enters... basicaly don't calculate the lowest number.

boxe 2
boxe 2
boxe 1
boxe 2
boxe 2
boxe 2

add them all except the box 1 because has the lowest number

so far my form calculate all 6 numbers which i dnt want to calculate the lowest


PHP Code:
 lblTotal.Text Val(txtGrOne.Text) + Val(txtGrTwo.Text) + Val(txtGrThree.Text) + Val(txtGrFour.Text) + Val(txtGrFive.Text) + Val(txtGrSix.Text)
        
lblSenYear.Text Val(lblTotal.Text) / 6

        lblTotalCredit
.Text Val(txtGone.Text) + Val(txtGtwo.Text)
        
lblPlacement.Text Val(lblTotalCredit.Text) / 2

        lblFinalCredit
.Text Val(txtGfOne.Text) + Val(txtGfTwo.Text) + Val(txtGfThree.Text) + Val(txtGfFour.Text) + Val(txtGfFive.Text)
        
lblFinal.Text Val(lblFinalCredit.Text) / 5

        lblAll
.Text Val(lblTotal.Text) + Val(lblFinalCredit.Text) + Val(lblTotalCredit.Text)

        
lblAverage.Text = (Val(lblSenYear.Text) + Val(lblFinal.Text) + Val(lblPlacement.Text)) / 
Reply With Quote
  #2  
Old 06-21-2010, 07:16 AM
lordofduct's Avatar
lordofduct lordofduct is offline
Centurion
 
Join Date: May 2010
Location: south florida yo
Posts: 120
Default

check out Math.Min(...), it returns the minimum of two values.

the .net version only returns the min of two values... not sure where the min of an array of values is, but here is basically how it can be done:

Code:
    Public Function Min(ByVal ParamArray args() As Double) As Double

        If args.Length = 0 Then Return Double.NaN

        Dim lowest As Double = args(0)

        For i As Integer = 1 To args.Length - 1
            If args(i) < lowest Then lowest = args(i)
        Next

        Return lowest
    End Function

With it you can find the lowest and just subtract it from the sum... remember that:

a + b + c + d - c == a + b + d
__________________
I'm a turtle... woooo
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
don't calculate the lowest number
don't calculate the lowest number
don't calculate the lowest number don't calculate the lowest number
don't calculate the lowest number
don't calculate the lowest number
don't calculate the lowest number don't calculate the lowest number don't calculate the lowest number don't calculate the lowest number don't calculate the lowest number don't calculate the lowest number don't calculate the lowest number
don't calculate the lowest number
don't calculate the lowest number
 
don't calculate the lowest number
don't calculate the lowest number
 
-->