小编Ant*_*yer的帖子

在 VBA 中实现接口时,实现的功能需要是私有的还是公共的?

我正在阅读这里创建类工厂:https : //rubberduckvba.wordpress.com/2018/04/24/factories-parameterized-object-initialization/我很困惑为什么他们将实现的函数设为私有,不会我们希望它们是公开的,以便我们可以访问它们?

VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "Something"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Type TSomething
    Bar As Long
    Ducky As String
End Type

Private this As TSomething
Implements ISomething

Public Function Create(ByVal initialBar As Long, ByVal initialDucky As String) As ISomething
    With New Something
        .Bar = initialBar
        .Ducky = initialDucky
        Set Create = .Self
    End With …
Run Code Online (Sandbox Code Playgroud)

oop excel vba interface implements

3
推荐指数
1
解决办法
253
查看次数

标签 统计

excel ×1

implements ×1

interface ×1

oop ×1

vba ×1