![]() ![]() Oorang's workaround is basically right - have a separate "init" method. You already have two correct answers you can't literally have a constructor with parameters in VBA. It's not great, but it's about as good as it's going to get with VBA/VB6. Public Property Get FirstName() As String If Not m_blnInitialized Then Err.Raise eStandardErrors.eNotInitialized Public Sub Initialize(ByVal ID As Long, Optional ByVal someOtherThing As String = vbNullString) A basic example might look like this: Option Explicit 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. As Jtolle indicated, this is simply not possible in VBA/VB6.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |