■ 클래스를 사용하는 방법을 보여준다.
▶ 클래스 사용하기 예제 (VB)
1 2 3 4 5 6 7 8 9 10 |
Dim pTestClass As TestClass Set pTestClass = New TestClass pTestClass.ValueA = 10 pTestClass.ValueB = 50 Print pTestClass.GetSummary() |
▶ 클래스 사용하기 예제 (VB)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
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 |