As Jtolle indicated, this is simply not possible in VBA/VB6. There is no perfect way to work around this but, what I personally do is create a Public/Friend sub call Initialize with the parameters I want (in VBA/VB6 you use "Optional" parameters for overloading) and then put a quick check in all exposed members of the class that throws an exception if you try to access them without running the initialize method. A basic example might look like this:
Option Explicit
Private m_blnInitialized As Boolean
Private m_lngID As Long
Private m_strFirstName As String
Public Sub Initialize(ByVal ID As Long, Optional ByVal someOtherThing As String = vbNullString)
If m_blnInitialized Then Me.Clear
m_lngID = ID
m_strFirstName = SomeLookUp()
If LenB(someOtherThing) Then
''Do something here.
End If
m_blnInitialized = True
End Sub
Public Property Get ID() As Long
If Not m_blnInitialized Then Err.Raise eStandardErrors.eNotInitialized
ID = m_lngID
End Property
Public Property Get FirstName() As String
If Not m_blnInitialized Then Err.Raise eStandardErrors.eNotInitialized
FirstName = m_strFirstName
End Property
Private Function SomeLookUp() As String
''perform magic on Me.ID
End Function
Public Sub LoadPicture()
If Not m_blnInitialized Then Err.Raise eStandardErrors.eNotInitialized
''More magic
End Sub
Public Sub Clear()
If Not m_blnInitialized Then Err.Raise eStandardErrors.eNotInitialized
m_strFirstName = vbNullString
m_lngID = 0&
m_blnInitialized = False
End Sub
It's not great, but it's about as good as it's going to get with VBA/VB6.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…