HighTechTalks DotNet Forums  

Classes

VB.net microsoft.public.dotnet.languages.vb


Discuss Classes in the VB.net forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Carlo B
 
Posts: n/a

Default Classes - 04-18-2004 , 07:01 AM






I’m getting an error “An unhandled exception of type
'System.NullReferenceException' occurred in 11_1_26.exe Additional
information: Object reference not set to an instance of an object.” It
points to st.num = CDbl(txtNumber.Text)
I cannot see what is wrong. Please help.


Dim statistic() 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
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 = statistic(50).average
End Sub
End Class
Class statistics
Private m_count As Integer
Private m_num 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()
Dim total As Double
total += m_num
End Sub
Function average() As Double
Dim av As Double
av = m_num / 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!

Reply With Quote
  #2  
Old   
AT
 
Posts: n/a

Default Re: Classes - 04-18-2004 , 07:17 AM






* Carlo B <carlob (AT) global (DOT) co.za> scripsit:
[...]

Double post!

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.