Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic (http://www.programmingforums.org/forum18.html)
-   -   not displaying lowest number (http://www.programmingforums.org/showthread.php?t=13450)

boatn19 Jun 30th, 2007 10:56 AM

not displaying lowest number
 
I am trying to display the lowest number using the for...each statement.
What is happening is either I get it to display the second number or the last number. Is my if statement in the correct location for starters and does it look the way it should or is it as messed up as me?


:


      Dim scores() As Integer = {78, 87, 95, 94, 77, 82, 81, 82, 65, 45, _
                                  66, 54, 32, 24, 100, 78, 86, 13, 92, 91}
        Dim lowest As Integer
        Dim x As Integer = 1

        For Each lowest In scores
            If scores(x) < lowest Then lowest = scores(x)

        Next lowest
        Me.xLowestLabel.Text = lowest.ToString()
    End Sub


Wizard1988 Jun 30th, 2007 11:05 AM

Look at your x variable, what is it supposed to do?

Infinite Recursion Jul 2nd, 2007 3:29 PM

x needs to put its best foot forward :)


All times are GMT -5. The time now is 6:13 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC