|
-
Sep 28th, 2000, 07:26 AM
#1
Thread Starter
Lively Member
Is there a way to make public constant in a class ? Or make something else near this ?
-
Sep 28th, 2000, 07:29 AM
#2
Addicted Member
Hi,
You could have a property that only has a Get procedure for it.
ie.
Code:
Private Const m_MyConst = 5
Public Property Get MyConst()
MyConst = m_MyConst
End Property
Without the Let procedure, MyConst will always be 5 and cannot be changed.
Hope this helps
Shaun
Web/Application Developer
VB6 Ent (SP5), Win 2000,SQL Server 2000
-
Sep 28th, 2000, 07:38 AM
#3
Thread Starter
Lively Member
Thanx a lot S@NSIS.
That's what I search.
Any idea for user-define type ?
-
Sep 28th, 2000, 08:00 AM
#4
Addicted Member
Hi,
There are many workarounds for this and you really shouldn't need a UDT inside a class. However, if you need to then try this
Code:
'Class to simulate UDT called clsUDT
Option Explicit
Private m_aString As String
Private m_aInteger As Integer
Private m_aDate As Date
Public Property Get aString() As String
aString = m_aString
End Property
Public Property Let aString(vData As String)
m_aString = vData
End Property
Public Property Get aInteger() As Integer
aInteger = m_aInteger
End Property
Public Property Let aInteger(vData As Integer)
m_aInteger = vData
End Property
Public Property Get aDate() As Date
aDate = m_aDate
End Property
Public Property Let aDate(vData As Date)
m_aDate = vData
End Property
'Class to provide interface for UDT
Dim m_MyUDT As clsUDT
Private Sub Class_Initialize()
Set m_MyUDT = New clsUDT
End Sub
Public Property Get myudt() As clsUDT
myudt = m_MyUDT
End Property
Public Property Let myudt(vData As clsUDT)
m_MyUDT = vData
End Property
'Add your own code for adding,removing clsUDT objects.
If you want say, an array of UDT's then you could set up another class to hold a collection of clsUDT with the usual add,remove etc methods.
Not sure if this is exactly what you are after but hopefully it may provide some pointers.
Cheers
Shaun
[Edited by S@NSIS on 09-28-2000 at 09:16 AM]
Web/Application Developer
VB6 Ent (SP5), Win 2000,SQL Server 2000
-
Sep 28th, 2000, 08:33 AM
#5
Thread Starter
Lively Member
Thanx.
It's not exactly what i have in mind, but it can work with my app.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|