Click here to Skip to main content
15,911,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can we create a Static constructor in VB.NET?
Posted

A Static Constructor of a class gets initialised and invoked when the assembly loads itself.
in VB.NET modules are equivalent of a static (shared) Class.
add a module
VB
'in a Module:
Sub New()
'your code goes here
End Sub
 
Share this answer
 
Possibly reading the VB.NET documentation (Shared Constructors[^])?
 
Share this answer
 
VB
Class ExplicitConstructor

    Shared Sub New()
        _message = "Hello World"
    End Sub

    Public Shared ReadOnly Property Message() As String
        Get
            Return _message
        End Get
    End Property

    Private Shared _message As String

End Class
 
Share this answer
 
Comments
Nara Har 2-Jan-12 8:39am    
This really help me. Thank you dear.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900