나는 당신이 말하는 것을 이해하는 경우, 이것은 클래스 모듈을 통해 수행 할 수 있습니다. VBA를 편집기에서
- , 삽입> 클래스 모듈 속성 창을 통해
- 변경 ( 예를 들어
Car
) 당신이 원하는에 클래스 모듈의 이름 (F4를 눌러 보이게에 경우 아직하지 않았다)
이제 클래스 모듈을 만들었으므로 변수 및/또는 속성을 정의 할 수 있습니다. 예제는 아래 Car
클래스 모듈로 갈 것입니다 당신의 모듈에서
Private carName As String
Private carSpeed As Integer
' Car Name
Public Property Get Name() As String
Name = carName
End Property
Public Property Let Name(result As String)
carName = result
End Property
' Car Speed
Public Property Get Speed() As Integer
Speed = carSpeed
End Property
Public Property Let Speed(result As Integer)
carSpeed = result
End Property
다음 자동차 이름과 속도를 유지하는 객체를 생성, 다음을 수행 할 수 있습니다
Sub CreateMyCars()
Dim slowCar as Car
Dim fastCar as Car
Set slowCar = New Car
Set fastCar = New Car
slowCar.Name = "GoKart"
slowCar.Speed = 35
fastCar.Name = "Ferarri"
fastCar.Speed = 185
End Sub
여기에 가서 : http://www.freevbcode.com/ShowCode.asp?ID=2970 - VB6에 대한 것이지만 VBA에서 동일해야합니다. –
이것은 또한 당신이 필요로하는 것을 가지고 있습니다. http://www.vb-helper.com/howto_interface_inheritance.html – user3357963