Ben
Ben

Reputation: 1032

Can a Visual Basic 6 Class Property Type be an Enum

I'm working on an old vb6 application (long story, .NET Framework is not available).

I want to know, can I declare a vb6 Class Property item as an Enum?

e.g.

Public Enum WinInetPort
    INTERNET_INVALID_PORT_NUMBER = 0
    INTERNET_DEFAULT_FTP_PORT = 21
    INTERNET_DEFAULT_GOPHER_PORT = 70
    INTERNET_DEFAULT_HTTP_PORT = 80
    INTERNET_DEFAULT_HTTPS_PORT = 443
    INTERNET_DEFAULT_SOCKS_PORT = 1080
End Enum

Class Module:

Private m_Port As WinInetPort
Public Property Get Port() As WinInetPort
    Port = m_Port
End Property
Public Property Let Port(val As WinInetPort)
    m_Port = val
End Property

But, I get errors when compiling

Only comments may appear after End Sub, End Function, or End Property

The error is highlighted on the next Private statement in the class.

I've read somewhere on the net vb6 classes can't expose Public Constants - is there a workaround?

Thanks

Upvotes: 4

Views: 4538

Answers (1)

John Smith
John Smith

Reputation: 66

Make sure all of your Private statements are placed above the Property declarations.

Upvotes: 5

Related Questions