David Cox
2013-01-02 01:38:53 UTC
I am using VB6 as a front end for a Access 97 database. I have been using
the following code in a class module to enter data in the database:
Private Type ScaleReceiptProps
ID As Long
RecNum As Long
ScType As GMScaleTypes
scDate As Date
Gross As Currency
Truck As Currency
LoadNum As String * 20
Description As String * 500
InvoiceDetailID As Long
CategoryID As Long
SaleValue As Currency
Grade As String * 50
RelatedReceipt As Long
End Type
Private mudtProps As ScaleReceiptProps
Public Property Let scDate(NewVal As String)
If Not mflgEditing Then Err.Raise 383
If Not IsDate(NewVal) Then
Err.Raise InputErr, "ScaleReceipt", ErrDate
End If
If DateValue(mudtProps.scDate) <> DateValue(NewVal) Then
mudtProps.scDate = DateValue(NewVal)
ValueChanged
End If
End Property
I Googled about dates in VB6, and I think this code may not be the best way
to do it. As long as the PC's regional settings are 'English US' it should
work fine. If the setting happens to get changed to something else at some
point in the life of the database I think there may be errors. Here is the
changed code:
Public Property Let scDate(NewVal As Date)
If Not mflgEditing Then Err.Raise 383
If format(mudtProps.scDate,"MM/DD/YYYY")<>format(NewVal,"MM/DD/YYYY")
then
mudtprops.scDate = format(NewVal,"MM/DD/YYYY")
ValueChanged
End If
End Property
The variable NewVal would receive a DateTimePicker value property. Is this
code safe for regional settings?
the following code in a class module to enter data in the database:
Private Type ScaleReceiptProps
ID As Long
RecNum As Long
ScType As GMScaleTypes
scDate As Date
Gross As Currency
Truck As Currency
LoadNum As String * 20
Description As String * 500
InvoiceDetailID As Long
CategoryID As Long
SaleValue As Currency
Grade As String * 50
RelatedReceipt As Long
End Type
Private mudtProps As ScaleReceiptProps
Public Property Let scDate(NewVal As String)
If Not mflgEditing Then Err.Raise 383
If Not IsDate(NewVal) Then
Err.Raise InputErr, "ScaleReceipt", ErrDate
End If
If DateValue(mudtProps.scDate) <> DateValue(NewVal) Then
mudtProps.scDate = DateValue(NewVal)
ValueChanged
End If
End Property
I Googled about dates in VB6, and I think this code may not be the best way
to do it. As long as the PC's regional settings are 'English US' it should
work fine. If the setting happens to get changed to something else at some
point in the life of the database I think there may be errors. Here is the
changed code:
Public Property Let scDate(NewVal As Date)
If Not mflgEditing Then Err.Raise 383
If format(mudtProps.scDate,"MM/DD/YYYY")<>format(NewVal,"MM/DD/YYYY")
then
mudtprops.scDate = format(NewVal,"MM/DD/YYYY")
ValueChanged
End If
End Property
The variable NewVal would receive a DateTimePicker value property. Is this
code safe for regional settings?