Ok, that is what was wrong, I already had stuff in there, and this was making its own array elements.
Here is the code of what reflects the array........the project is 6 forms and 2 classes , so somestuff comes over from other forms , but should be able to follow along to get an idea of what is going on .
Private Sub newstudentButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles newstudentButton.Click
summaryForm.Activate()
studentID(loopcountInteger) = summaryForm.completeaverage
If loopcountInteger = 24 Then
newstudentButton.Enabled = False
MessageBox.Show("This will be the last Student to play the game at this time", "Max Users", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else : Me.newstudentButton.Enabled = True
loopcountInteger += 1
TextBox1.Text = (loopcountInteger).ToString
ArithmeClass.arithclasstotaleventsinteger = 0 : ArithmeClass.arithclasstotalrightinteger = 0
moneyClass.moneyclasstotaleventsdecimal = 0 : moneyClass.moneyclasstotalrightDecimal = 0
End If
Then for the array data
Public Function completeaverage() As Decimal
'adds up the total right and wrong decimal from both classes and makes one average
CompleteTotalrightDecimal = (moneyClass.moneyclasstotalrightDecimal + ArithmeClass.arithclasstotalrightinteger)
CompleteTotaleventsDecimal = (moneyClass.moneyclasstotaleventsdecimal + ArithmeClass.arithclasstotaleventsinteger)
Averageinteger = (CompleteTotalrightDecimal / CompleteTotaleventsDecimal)
Return Averageinteger
End Function
Then I do the average for all the arrays, which isn't apart of the array , but only fills a textbox in the summary form.
The thing I am trying to use for the max value of the array is this
Public Function MaxValOfIntArray(ByRef studentID As Decimal) As Decimal
'This function gives max value of int array without sorting an array
MaxIntegersamount = 0
For i = 0 To UBound(welcomeForm.studentID)
If welcomeForm.studentID(i) > MaxValOfIntArray Then
MaxIntegersamount = i
End If
Next
' index of max value is MaxValOfIntArray
Return MaxIntegersamount
End Function
But I think it only returns an index, and I need an actual value such as "87%"
Then it fills up the textboxes in the summary.
Private Sub summaryForm_load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
currentaveTextBox.Text = completeaverage.ToString("P")
If welcomeForm.loopcountInteger > 0 Then
completeaveTextBox.Text = averageofAllarrays.ToString("P")
'Me.maxscoreTextBox.Text = Me.MaxValOfIntArray.tostring
Me.minscoreTextBox.Text = Me.minintegersindex.ToString
End If
Catch
MessageBox.Show("Not Enough Information for Summary", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Hopefully someone can figure this out , I can explain anything that doesn't seem right. Everything is working , except max and min
thanks
Joe