|
-
Apr 15th, 2003, 07:04 AM
#1
Thread Starter
Member
Class attributes (NewB QUESTION)(RESOLVED)
Currently i have a class called clsLoanPolicy which is as below:
VB Code:
Option Explicit
Private cMaxLoanLimit As Currency
Private iOverdueCharges As Integer
Public Property Get MaxLoanLimit() As Variant
MaxLoanLimit = cMaxLoanLimit
End Property
Public Property Let MaxLoanLimit(ByVal vNewValue As Variant)
cMaxLoanLimit = vNewValue
End Property
Public Property Get OverdueCharges() As Variant
OverdueCharges = iOverdueCharges
End Property
Public Property Let OverdueCharges(ByVal vNewValue As Variant)
iOverdueCharges = vNewValue
End Property
What must i add in the class that will set the cMaxLoanLimit and iOverdueCharges as 200 and 2 respectively.
Then when users create objects of the class, they can use the getters to get the attributes value which should show 200 and 2
and also to use setters to set new attributes values.
In other words, making this class a sort of file to permanently store the attributes.
Last edited by yyayl; Apr 15th, 2003 at 07:17 AM.
-
Apr 15th, 2003, 07:10 AM
#2
You can use the Class_Initialize event to set initial values to cMaxLoanLimit and iOverdueCharges.
VB Code:
Private Sub Class_Initialize()
cMaxLoanLimit = 200
iOverdueCharges = 2
End Sub
May I ask why your property procedures returns and accept Variants when MaxLoanLimit should be in Currency and OverdueCharges in Integer according to your private variables?
-
Apr 15th, 2003, 07:15 AM
#3
Thread Starter
Member
Thx for the ans Joacim
May I ask why your property procedures returns and accept Variants when MaxLoanLimit should be in Currency and OverdueCharges in Integer according to your private variables?
ermm.... no idea.
Isnt variant the default vb data type and holds any type of data?
-
Apr 15th, 2003, 07:17 AM
#4
A variant can be ANY data type and due to this is scoffs a lot more memory. Since your properties are for a specific datatype, ie currency, then the property should also be curreny...
-
Apr 15th, 2003, 07:21 AM
#5
Thread Starter
Member
-
Apr 15th, 2003, 07:22 AM
#6
not to mention the fact that you could pass text to it rather than numbers. if you use the proper data type then VB will force the coder to pass valid data to the class
-
Apr 15th, 2003, 07:24 AM
#7
Thread Starter
Member
Originally posted by si_the_geek
not to mention the fact that you could pass text to it rather than numbers. if you use the proper data type then VB will force the coder to pass valid data to the class
ahhh......
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
|