Hey, I need to find the min and max vaule on an array. The .max function works but .min keeps showing zero.
Public Class Program_2_Grade
Dim max As Integer
Dim min As Integer
Dim average As Integer
Dim average1 As Integer
Dim grade As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = Nothing Or TextBox1.Text > 100 Then
MsgBox("Doesn't Meet Grade Requirements", MsgBoxStyle.Exclamation, "Error")
TextBox1.Clear()
TextBox1.Focus()
counter = 0
Else
grade_enter(counter) = TextBox1.Text
TextBox1.Clear()
TextBox1.Focus()
counter = counter + 1
If counter = grade_amount Then
max = grade_enter.Max()
min = grade_enter.Min()
For i As Integer = 0 To counter
average = average + grade_enter(i) / counter
average1 = average1 + grade_enter(i) - grade_enter.Min / counter
Next
Select Case average
Case 30 To 49
grade = "C"
Case 50 To 69
grade = "B"
Case 70 To 100
grade = "A"
Case Else
grade = "Fail"
End Select
If (Program_2.CheckBox1.Checked = True) Then
Program_2.TextBox4.Text = _
("Name:" & " " & (Program_2.TextBox1.Text) & vbNewLine & _
"Class: " & (Program_2.TextBox2.Text) & vbNewLine & _
"Number Of Grades:" & " " & (Program_2.TextBox3.Text) & vbNewLine & _
"Max:" & " " & max & vbNewLine & _
"Min:" & " " & min & vbNewLine & _
"Average:" & " " & average1 & vbNewLine) & _
"Grade:" & " " & grade & vbNewLine & _
"Dropped Lowest Grade"
Else
Program_2.TextBox4.Text = _
("Name:" & " " & (Program_2.TextBox1.Text) & vbNewLine & _
"Class: " & (Program_2.TextBox2.Text) & vbNewLine & _
"Number Of Grades:" & " " & (Program_2.TextBox3.Text) & vbNewLine & _
"Max:" & " " & max & vbNewLine & _
"Min:" & " " & min & vbNewLine & _
"Average:" & " " & average & vbNewLine) & _
"Grade:" & " " & grade & vbNewLine
End If
Me.Close()
average = 0
average1 = 0
counter = 0
End If
End If
End Sub
btw my arrays are set at global level
thanks