|
-
Nov 7th, 2000, 04:17 AM
#1
Thread Starter
Hyperactive Member
Hi Guys
I have recently taken over a VBA prog that seems to work with classes. I have never worked with classes before and it is a bit of a mystery to me. Here is some of the code.
Private moDatabase As Database
Private moRecordset As Recordset
Private Const COLUMN_SOURCE As Integer = 0
Private Const COLUMN_INVPG As Integer = 1
Private Const COLUMN_TELE As Integer = 2
Private Const COLUMN_QTY As Integer = 3
Private Const COLUMN_ORDERNR As Integer = 4
Private Const COLUMN_COMPANY As Integer = 5
Private Const COLUMN_CORRECTION As Integer = 6
Private Const COLUMN_RECDATE As Integer = 7
Private Const COLUMN_SHIPPOINT As Integer = 8
Property Let Source(ByVal bvFld As String)
moRecordset.Fields(COLUMN_SOURCE) = bvFld
End Property
Property Get Source() As String
Source = moRecordset.Fields(COLUMN_SOURCE)
End Property
Property Let InvPg(ByVal bvFld As String)
moRecordset.Fields(COLUMN_INVPG) = bvFld
End Property
Property Get InvPg() As String
InvPg = moRecordset.Fields(COLUMN_INVPG)
End Property
there is a let and get for each of the constants listed above. Can anyone help me understand what this is all about as I am a bit bamboozeled by it and have no one to ask.
There is also a lot of this stuff:
Property Get CDSRecordSet() As Recordset
Set CDSRecordSet = moRecordset
End Property
Public Sub SetUpdateMode()
moRecordset.Edit
End Sub
Public Sub SetAddMode()
moRecordset.AddNew
Many thanks
Locutus
End Sub
-
Nov 7th, 2000, 04:48 AM
#2
Fanatic Member
Classes
Loooks like the person who wrote this need to go back to class.
Encapsulating all properties within a class in Let and Get statements is fine, but there is no point having a Let with a CONST - this should be a read only property and is wrongly implemented. There should be no Let property for these. Maybe they were not CONST originally?
As for encapsulating the database methods, fine, but unless you add something (like operation logging, error checking etc.) there is no point.
These property statements will simply let you access the values of the constants without having direct access to the constants themselves (that is why they are Private)
If you are not sure about Let and Get, check out the help file. It is reasonably clear.
Cheers,
Paul.
Not nearly so tired now...
Haven't been around much so be gentle...
-
Nov 7th, 2000, 09:48 AM
#3
Thread Starter
Hyperactive Member
Thanx
Thanx for your comments paulw, anyone else care to comment ?
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
|