VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



How to Create Class In VB.NET

by Hari Reddy (5 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 12th July 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

How to Create Class In VB.NET

Rate How to Create Class In VB.NET




Module General
    
    Public Sub Main()
        
        Dim aCBook As New CBook()
        
        With aCBook
            
            .BookID = "1234"
            .BookTitle = "Programming with VB.NET"
            .Author = "Hari Reddy"
            .Publisher = "Digital Publishing Solutions"
            
            System.Console.WriteLine(.BookID)
            System.Console.WriteLine(.BookTitle)
            System.Console.WriteLine(.Author)
            System.Console.WriteLine(.Publisher)
            System.Console.WriteLine(.Price)
            
        End With
        
        aCBook = Nothing
        
    End Sub
    
End Module


'Paste the following code in class. here u have create general module class--from the project menu add new class

Option Explicit On 
Option Strict On

Public Class CBook
    
    Private m_sBookID As String
    Private m_sBookTitle As String
    Private m_sPublisher As String
    Private m_sAuthor As String
    Private m_sngPrice As System.Currency
    
    Public Property BookID() As String
        Get
            Return m_sBookID
        End Get
        Set
            m_sBookID = Value
        End Set
    End Property
    
    Public Property BookTitle() As String
        Get
            Return m_sBookID
        End Get
        Set
            m_sBookTitle = Value
        End Set
    End Property
    
    Public Property Publisher() As String
        Get
            Return m_sPublisher
        End Get
        Set
            m_sPublisher = Value
        End Set
    End Property
    
    Public Property Author() As String
        Get
            Return m_sAuthor
        End Get
        Set
            m_sAuthor = Value
        End Set
    End Property
    
    Public Property Price() As System.Currency
        Get
            Return m_sngPrice
        End Get
        Set
            m_sngPrice = Value
        End Set
    End Property
End Class


Download this snippet    Add to My Saved Code

How to Create Class In VB.NET Comments

No comments have been posted about How to Create Class In VB.NET. Why not be the first to post a comment about How to Create Class In VB.NET.

Post your comment

Subject:
Message:
0/1000 characters