brightak
asked on
Object reference not set to an instance of an object.
I keep getting an error when I try to invoke a class in my VB 2005 project. What follows is my code:
Public Class OpticalDensity
Public Key As Double
Public Value As Double
Public Log10 As Double
Public Ln As Double
Public Log10LnProd As Double
Public Result As Double
Public Sub New(ByVal dblKey As Double, ByVal dblValue As Double, Optional ByVal dblLnSub As Double = 0)
Key = dblKey
Value = dblValue
Log10 = Math.Log(Key) / Math.Log(10.0#)
Ln = Math.Log(dblLnSub / (1 - dblLnSub)) / Math.Log(2.718281828)
Log10LnProd = Log10 * Ln
End Sub
End Class
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- -------
Public Class OpticalDensities
Private mCol As Collection
Protected Friend ZeroOD As Double
...
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- -------
Public Sub Add(ByVal dblKey As Double, ByVal dblValue As Double)
Dim od As New OpticalDensity(dblKey, dblValue, dblValue / ZeroOD)
mCol.Add(od) 'HERE IS WHERE I GET THE ERROR
...
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- -------
Thanks for your help.
brightak
Public Class OpticalDensity
Public Key As Double
Public Value As Double
Public Log10 As Double
Public Ln As Double
Public Log10LnProd As Double
Public Result As Double
Public Sub New(ByVal dblKey As Double, ByVal dblValue As Double, Optional ByVal dblLnSub As Double = 0)
Key = dblKey
Value = dblValue
Log10 = Math.Log(Key) / Math.Log(10.0#)
Ln = Math.Log(dblLnSub / (1 - dblLnSub)) / Math.Log(2.718281828)
Log10LnProd = Log10 * Ln
End Sub
End Class
--------------------------
Public Class OpticalDensities
Private mCol As Collection
Protected Friend ZeroOD As Double
...
--------------------------
Public Sub Add(ByVal dblKey As Double, ByVal dblValue As Double)
Dim od As New OpticalDensity(dblKey, dblValue, dblValue / ZeroOD)
mCol.Add(od) 'HERE IS WHERE I GET THE ERROR
...
--------------------------
Thanks for your help.
brightak
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER