Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Public variable in a Module not declared?

Status
Not open for further replies.

rdeleon

IS-IT--Management
Jun 11, 2002
114
US
I am trying to upgrade a VB6 dll to VB.NET and I am brand new to VB.NET.

I used the conversion tool and the dll compiles, but I get {"Object reference not set to an instance of an object."} errors in variables that I have defined in a module.

Here is my simplified code.

In module:
Public VersionMe As New VersionNumber

Classes:
Public Class VersionNumber
Public ReadOnly Property ValidityCheck () As boolean
Get
ValidityCheck = true
End Get
End Property
End Class

Public Class WinReg
Public Sub New()
MyBase.New()
Class_Initialize_Renamed()
End Sub
Private Sub Class_Initialize_Renamed()
If Not VersionMe.ValidityCheck Then <-- error here
MsgBox("Invalid Installation")
Exit Sub
End If
End Sub
End Class


When I try to instantiate a WinReg object, I get the error where I have indicated.

Thanks in advance.
 
Assuming everything else you are leaving out is right then...
Code:
    Public Class VersionNumber
        Public ReadOnly Property ValidityCheck() As Boolean
            Get
                ValidityCheck = True
            End Get
        End Property
    End Class

    Public Class WinReg
        Public Sub New()
            MyBase.New()
            Class_Initialize_Renamed()
        End Sub
        Private Sub Class_Initialize_Renamed()
            [red]Dim VersionMe As New VersionNumber[/red] [green]'Or where ever you decide to delcare it.[/green]

            If Not VersionMe.ValidityCheck Then '<-- error here
                MsgBox("Invalid Installation")
                Exit Sub
            End If
        End Sub
    End Class

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top