Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.basic.visual.misc > #1689

Dates and Regional settings

From "David Cox" <d.cox@hushmail.com>
Newsgroups comp.lang.basic.visual.misc
Subject Dates and Regional settings
Date 2013-01-01 19:38 -0600
Organization A noiseless patient Spider
Message-ID <kc033i$rcg$1@dont-email.me> (permalink)

Show all headers | View raw


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? 

Back to comp.lang.basic.visual.misc | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Dates and Regional settings "David Cox" <d.cox@hushmail.com> - 2013-01-01 19:38 -0600
  Re: Dates and Regional settings ralph <nt_consulting@yahoo.com> - 2013-01-01 20:49 -0600
    Re: Dates and Regional settings "David Cox" <d.cox@hushmail.com> - 2013-01-01 21:16 -0600
      Re: Dates and Regional settings ralph <nt_consulting@yahoo.com> - 2013-01-01 22:25 -0600
  Re: Dates and Regional settings Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-01-03 19:13 +0000
    Re: Dates and Regional settings "David Cox" <d.cox@hushmail.com> - 2013-01-03 19:23 -0600
      Re: Dates and Regional settings Deanna Earley <dee.earley@icode.co.uk> - 2013-01-04 09:47 +0000

csiph-web