我想在全球范围内声明类是我的例子:
我想使用看起来完全像这样的类 clsIEError:
Option Explicit
Public Sub m(msg As String, Optional title As String = "Title:")
'Attribute Value.VB_UserMemId = 0
'this method will be used as defualt method
'and here are attributes msg and title used to create some inteface
End Sub
这就是它的工作原理示例1:
Sub CATMain()
Dim ie As clsIEError
Set ie = New clsIEError
ie "test", "title"
Set ie = Nothing
End Sub
但我的问题是我想在全球范围内拥有它示例2:
Option Explicit
Public ie As clsIEError
Private Function Init()
Set ie = New clsIEError
End Function
Sub CATMain()
Call Init
' and to use it same as in example 1
ie "test", "title"
' but i am able to use it only like:
' ie.m "test", "title" 'works as expected
Set ie = Nothing
End Sub
为什么使用公共默认方法不起作用?