|
-
May 12th, 2009, 04:21 AM
#1
Thread Starter
New Member
Trouble Getting Elements Into My Array Correctly
Hi All, I'm back with more novice questions.
In this case I'm trying to create a number analysis app. I'm required to declare an array and get the data for the array using ten text boxes. Why, because my instructor said so.
My problem is my event is returning zero. Therefore I believe my code is somehow flawed. Can somebody examine my code and let me know where I'm going wrong.
My approach is to create functions that calculate the required metrics. I have only tried to code one function to date. If I can get help making one function work, I will be able to do the others . Can someone pleas take a look at my code and help me identify where I'm off.
Thanks
Public Class Form1
Dim decScore0, decScore1, decScore2, decScore3, decScore4 As Decimal
Dim decScore5, decScore6, decScore7, decScore8, decScore9 As Decimal
Dim decObservationArray() As Decimal = {decScore0, decScore1, decScore2, decScore3, _
decScore4, decScore5, decScore6, decScore7, decScore8, decScore9}
Private Sub btnCalculateStatistics_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculateStatistics.Click
lblMin.Text = Minimum().ToString
lblMax.Text = Maximum().ToString
lblSum.Text = Sum().ToString
lblAverage.Text = Average().ToString
End Sub
Public Function Minimum()
decScore0 = CDec(txtScore0.Text)
decScore1 = CDec(txtScore1.Text)
decScore2 = CDec(txtScore2.Text)
decScore3 = CDec(txtScore3.Text)
decScore4 = CDec(txtScore4.Text)
decScore5 = CDec(txtScore5.Text)
decScore6 = CDec(txtScore6.Text)
decScore7 = CDec(txtScore7.Text)
decScore8 = CDec(txtScore8.Text)
decScore9 = CDec(txtScore9.Text)
Dim intCount As Integer = 1
Dim decMinimum As Decimal = decObservationArray(0)
For intCount = 1 To decObservationArray.Length - 1
If decObservationArray(intCount) < decMinimum Then
decMinimum = decObservationArray(intCount)
End If
Next intCount
Return decMinimum
End Function
Public Function Maximum() As Decimal
End Function
Public Function Sum() As Decimal
End Function
Public Function Average() As Decimal
End Function
Public Function ClearBoxes() As Decimal
txtScore0.Clear()
txtScore1.Clear()
txtScore2.Clear()
txtScore3.Clear()
txtScore4.Clear()
txtScore5.Clear()
txtScore6.Clear()
txtScore7.Clear()
txtScore8.Clear()
txtScore9.Clear()
End Function
Private Sub btnClearAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClearAll.Click
ClearBoxes()
End Sub
End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|