[VB] 클래스 사용하기

VB 2015.05.31 09:00

■ 클래스 사용하기 예제

----------------------------------------------------------------------------------------------------

Dim pTestClass As TestClass

 

Set pTestClass = New TestClass

 

pTestClass.ValueA = 10

pTestClass.ValueB = 50

 

Print pTestClass.GetSummary()

----------------------------------------------------------------------------------------------------

 

■ 클래스 사용하기 예제

----------------------------------------------------------------------------------------------------

Option Explicit

 

Private m_nValueA As Integer

 

Private m_nValueB As Integer

 

Private Sub Class_Initialize()

 

    m_nValueA = 0

    m_nValueB = 0

 

End Sub

 

Public Property Get ValueA() As Integer

 

    ValueA = m_nValueA

 

End Property

 

Public Property Let ValueA(nValue As Integer)

 

    m_nValueA = nValue

 

End Property

 

Public Property Get ValueB() As Integer

 

    ValueB = m_nValueB

 

End Property

 

Public Property Let ValueB(nValue As Integer)

 

    m_nValueB = nValue

 

End Property

 

Public Function GetSummary() As Integer

 

    GetSummary = m_nValueA + m_nValueB

 

End Function

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요