Dates

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Oin Zea

    Dates

    Greetings;

    What is the best code efficient way to check an textbox for proper date
    format? ea. mm/did/by

    example;

    If text.text not equal to date format then . . .



  • Oin Zea

    #2
    Re: Dates

    correction:

    "Oin Zea" <OinZea@hotmail .com> wrote in message
    news:Fu3Dc.1026 $G2.886@fe39.us enetserver.com. ..[color=blue]
    > Greetings;
    >
    > What is the best code efficient way to check an textbox for proper date
    > format? ea. mm/dd/yy
    >
    > example;
    >
    > If text.text not equal to date format then . . .
    >
    >
    >[/color]



    Comment

    • Lapointe

      #3
      Re: Dates

      Hello, i know 2 way to do that easilly,
      1- you can look for this format mm/dd/yyyy iy mm >= to 12 ( not realy good
      but if you put a good exemple on the side, it will be ok.
      2- the best way is to use the date manager in vb6, add it in the controle
      add on, and make a new form for that when he want to select the date, so,
      you be sure of the date

      if you want more info, send me an email

      Zeddex
      "Oin Zea" <OinZea@hotmail .com> a écrit dans le message news:
      ox3Dc.1034$G2.5 21@fe39.usenets erver.com...[color=blue]
      > correction:
      >
      > "Oin Zea" <OinZea@hotmail .com> wrote in message
      > news:Fu3Dc.1026 $G2.886@fe39.us enetserver.com. ..[color=green]
      > > Greetings;
      > >
      > > What is the best code efficient way to check an textbox for proper date
      > > format? ea. mm/dd/yy
      > >
      > > example;
      > >
      > > If text.text not equal to date format then . . .
      > >
      > >
      > >[/color]
      >
      >
      >[/color]


      Comment

      • Steve Gerrard

        #4
        Re: Dates


        "Oin Zea" <OinZea@hotmail .com> wrote in message
        news:ox3Dc.1034 $G2.521@fe39.us enetserver.com. ..[color=blue]
        > correction:
        >
        > "Oin Zea" <OinZea@hotmail .com> wrote in message
        > news:Fu3Dc.1026 $G2.886@fe39.us enetserver.com. ..[color=green]
        > > Greetings;
        > >
        > > What is the best code efficient way to check an textbox for proper[/color][/color]
        date[color=blue][color=green]
        > > format? ea. mm/dd/yy
        > >
        > > example;
        > >
        > > If text.text not equal to date format then . . .
        > >
        > >[/color][/color]

        If IsDate(Text1.Te xt) Then
        Text1.Text = Format(CDate(Te xt1.Text),"mm/dd/yyyy")
        Else
        Text1.Text = "-invalid date-"
        End If


        Comment

        • Rick Rothstein

          #5
          Re: Dates

          > correction:[color=blue]
          >
          > "Oin Zea" <OinZea@hotmail .com> wrote in message
          > news:Fu3Dc.1026 $G2.886@fe39.us enetserver.com. ..[color=green]
          > > Greetings;
          > >
          > > What is the best code efficient way to check an textbox for proper[/color][/color]
          date[color=blue][color=green]
          > > format? ea. mm/dd/yy[/color][/color]

          You can't... not reliably at least. If the user types in 02/03/04, can
          you be absolutely sure your user meant 02 to be the month, 03 to be the
          day and 04 to be the year? Hell, they might have been trying to enter
          April 2, 2003 for all you know. Your best bet is to add a DatePicker
          (DTPicker) control to take your user's date input. Go to
          Project/Components in VB's IDE menu and select Microsoft Windows Common
          Controls-2 6.0; it's in the group of controls that get added. The
          DatePicker control will allow your user to pick the date from a calendar
          display where there can be no confusion as to what was entered (and only
          valid date values are permitted to be entered, so there is no validation
          checking required).

          Rick - MVP

          Comment

          • J French

            #6
            Re: Dates

            On Sat, 26 Jun 2004 04:12:13 -0400, "Rick Rothstein"
            <rickNOSPAMnews @NOSPAMcomcast. net> wrote:

            <snip>
            [color=blue]
            > Go to
            >Project/Components in VB's IDE menu and select Microsoft Windows Common
            >Controls-2 6.0; it's in the group of controls that get added. The
            >DatePicker control will allow your user to pick the date from a calendar
            >display where there can be no confusion as to what was entered (and only
            >valid date values are permitted to be entered, so there is no validation
            >checking required).[/color]

            Gawd, what a horrible control.

            Since I have had users entering dates into my Apps since 1977, I can
            safely say that using that type of approach would have cut their
            productivity by 50% - at least
            - I can think of certain clients who would have lynched me

            My approach is different.
            Let them enter anything they want in there
            - 1.1.01
            - 010101
            - 1-1-1
            - 1/1/1
            - C - Today
            - C+1 - Tomorrow
            Then decifer it and reformat it in a sensible manner
            Then /redisplay/ it eg: 01-01-2001
            Then (if possible) do 'sanity checks'

            If the date is 'internally invalid' eg: 32nd August, then show the
            punter what they have entered, tell them 'INVALID DAY' in red in a
            Label, and let them edit it to get it right.

            The thing about the people at Microsoft is that they have no
            experience of fast bulk data entry.

            I do however, totally agree that IsDate will decide that the most
            peculiar things are valid dates, and CDate compounds the problem.

            I have posted what I use a few times
            Here is a link: http://tinyurl.com/yt53h

            It is extremely old code, but I find it utterly reliable (up to some
            leap year in about 2100)
            Also it is for the European date format, but that is easily tweaked


            Comment

            • Rick Rothstein

              #7
              Re: Dates

              > <snip>[color=blue]
              >[color=green]
              > > Go to
              > >Project/Components in VB's IDE menu and select Microsoft Windows[/color][/color]
              Common[color=blue][color=green]
              > >Controls-2 6.0; it's in the group of controls that get added. The
              > >DatePicker control will allow your user to pick the date from a[/color][/color]
              calendar[color=blue][color=green]
              > >display where there can be no confusion as to what was entered (and[/color][/color]
              only[color=blue][color=green]
              > >valid date values are permitted to be entered, so there is no[/color][/color]
              validation[color=blue][color=green]
              > >checking required).[/color]
              >
              > Gawd, what a horrible control.[/color]

              I'll admit this isn't one of Microsoft's best efforts control-wise, but
              I really don't think it is a "gawd horrible" control either.

              [color=blue]
              > Since I have had users entering dates into my Apps since 1977, I can
              > safely say that using that type of approach would have cut their
              > productivity by 50% - at least
              > - I can think of certain clients who would have lynched me[/color]

              As well as move through the calendar in its drop-down state with the
              supplied arrow keys, you do realize that you can click on the Month Name
              to select a new month from a drop down and click on the Year and select
              a new year from the spinners that popup, right? Aside from typing
              numbers and tabbing from field to field, it is also possible to enter a
              date in the non-dropped-down state by using nothing more than arrow
              keys. Up/Down arrows move the number in the highlighted field up or down
              one number for each click and the right/left arrows move between fields.
              Or your users could use a combination of these entry methods for the
              non-dropped-down state.

              [color=blue]
              > My approach is different.
              > Let them enter anything they want in there
              > - 1.1.01
              > - 010101
              > - 1-1-1
              > - 1/1/1
              > - C - Today
              > - C+1 - Tomorrow
              > Then decifer it and reformat it in a sensible manner
              > Then /redisplay/ it eg: 01-01-2001
              > Then (if possible) do 'sanity checks'
              >
              > Also it is for the European date format, but that is easily tweaked[/color]

              That's fine as far as it goes, but it still has the problem of not
              addressing an international community. And building in code to decipher
              the local settings for month/day order wouldn't solve every possible
              problem... if I were to come over to visit you and just happen to use
              one of your programs (think international company with travel/meetings
              at, say, the home headquarters), then when I enter 07/04/2004 next week,
              your program would assume I meant April 7th when actually I was thinking
              July 4th. A select-from-a-calendar-display would eliminate that problem.

              [color=blue]
              > It is extremely old code[/color]

              Yes, it is. You might consider modernizing it for VB6... I think you
              could cut it down to about half (or less) of its current size.


              Rick - MVP

              Comment

              • J French

                #8
                Re: Dates

                On Sat, 26 Jun 2004 11:20:53 -0400, "Rick Rothstein"
                <rickNOSPAMnews @NOSPAMcomcast. net> wrote:
                [color=blue][color=green]
                >> <snip>[/color][/color]
                [color=blue][color=green]
                >>
                >> Gawd, what a horrible control.[/color]
                >
                >I'll admit this isn't one of Microsoft's best efforts control-wise, but
                >I really don't think it is a "gawd horrible" control either.[/color]

                Your aesthetics are more liberal than mine
                [color=blue][color=green]
                >> Since I have had users entering dates into my Apps since 1977, I can
                >> safely say that using that type of approach would have cut their
                >> productivity by 50% - at least
                >> - I can think of certain clients who would have lynched me[/color]
                >[/color]

                <snip>
                [color=blue]
                >Or your users could use a combination of these entry methods for the
                >non-dropped-down state.[/color]

                Yes, I realize that, but for some odd reason my users like to type
                quickly
                - the idea of tabbing /within/ what looks to them like a Textbox would
                give them apoplexy
                [color=blue]
                >[color=green]
                >> My approach is different.
                >> Let them enter anything they want in there
                >> - 1.1.01
                >> - 010101
                >> - 1-1-1
                >> - 1/1/1
                >> - C - Today
                >> - C+1 - Tomorrow
                >> Then decifer it and reformat it in a sensible manner
                >> Then /redisplay/ it eg: 01-01-2001
                >> Then (if possible) do 'sanity checks'
                >>
                >> Also it is for the European date format, but that is easily tweaked[/color]
                >
                >That's fine as far as it goes, but it still has the problem of not
                >addressing an international community. And building in code to decipher
                >the local settings for month/day order wouldn't solve every possible
                >problem... if I were to come over to visit you and just happen to use
                >one of your programs (think international company with travel/meetings
                >at, say, the home headquarters), then when I enter 07/04/2004 next week,
                >your program would assume I meant April 7th when actually I was thinking
                >July 4th. A select-from-a-calendar-display would eliminate that problem.[/color]

                It is unlikely that you would use any of my Apps

                If I had anything that had to run in the USA or Europe, then the Date
                format would be user configurable

                The company I used to work for had hundreds of systems worldwide, and
                it was not uncommon for an American to be using USA settings on a
                European machine in Europe
                - or a European to be working in the USA
                (sorry that should be present tense - they are still motoring)[color=blue]
                >[color=green]
                >> It is extremely old code[/color]
                >
                >Yes, it is. You might consider modernizing it for VB6... I think you
                >could cut it down to about half (or less) of its current size.[/color]

                I could indeed, but that code exists in almost identical form in PDS7
                (Basic7) and in Delphi
                - best to keep a common 'code base'

                Practically, I dislike tinkering with widely used routines

                Also, although the code would be half its length, the chances are that
                it would compile to the same thing anyway


                Comment

                Working...