Hi
I'm not quite sure what is meant with 'enable 'option strict on' to
solve the problem.
I've now got it to show 'NaN' in the textbox because I have referenced
'addnumber' in the 'average' function. But it is still not giving me the
average.
Any ideas?
Thanks
Dim statistic(50) As statistics
Dim lastnumber As Integer
Private Sub btnRecord_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnRecord.Click
Dim st As statistics
st = New statistics()
lastnumber += 1
st.num = CDbl(txtNumber.Text)
statistic(lastnumber) = st
txtNumber.Text = 0
txtNumber.Focus()
End Sub
Private Sub btnAverage_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnAverage.Click
txtAverage.Text = CStr(statistic(lastnumber).average)
End Sub
End Class
Class statistics
Private m_count As Integer
Private m_num As Double
Public total As Double
Public Property count() As Integer
Get
Return m_count
End Get
Set(ByVal Value As Integer)
m_count = Value
End Set
End Property
Public Property num() As Double
Get
Return m_num
End Get
Set(ByVal Value As Double)
m_num = Value
End Set
End Property
Sub addnumber(ByVal m_num)
total = m_num
total += CDbl(total)
End Sub
Function average() As Double
Dim av As Double
Dim addnumber As Double = total
av = CDbl(addnumber / m_count)
Return av
End Function
End Class
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!