473,325 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

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 . . .

Jul 17 '05 #1
7 4239
correction:

"Oin Zea" <Oi****@hotmail.com> wrote in message
news:Fu***************@fe39.usenetserver.com...
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 . . .


Jul 17 '05 #2
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" <Oi****@hotmail.com> a écrit dans le message news:
ox***************@fe39.usenetserver.com...
correction:

"Oin Zea" <Oi****@hotmail.com> wrote in message
news:Fu***************@fe39.usenetserver.com...
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 . . .


Jul 17 '05 #3

"Oin Zea" <Oi****@hotmail.com> wrote in message
news:ox***************@fe39.usenetserver.com...
correction:

"Oin Zea" <Oi****@hotmail.com> wrote in message
news:Fu***************@fe39.usenetserver.com...
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 . . .


If IsDate(Text1.Text) Then
Text1.Text = Format(CDate(Text1.Text),"mm/dd/yyyy")
Else
Text1.Text = "-invalid date-"
End If
Jul 17 '05 #4
> correction:

"Oin Zea" <Oi****@hotmail.com> wrote in message
news:Fu***************@fe39.usenetserver.com...
Greetings;

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


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

Jul 17 '05 #5
On Sat, 26 Jun 2004 04:12:13 -0400, "Rick Rothstein"
<ri************@NOSPAMcomcast.net> wrote:

<snip>
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).


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
Jul 17 '05 #6
> <snip>
Go to
Project/Components in VB's IDE menu and select Microsoft Windows CommonControls-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 calendardisplay where there can be no confusion as to what was entered (and onlyvalid date values are permitted to be entered, so there is no validationchecking required).
Gawd, what a horrible control.


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.

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
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.

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
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.

It is extremely old code


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

Jul 17 '05 #7
On Sat, 26 Jun 2004 11:20:53 -0400, "Rick Rothstein"
<ri************@NOSPAMcomcast.net> wrote:
<snip>
Gawd, what a horrible control.
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.


Your aesthetics are more liberal than mine
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


<snip>
Or your users could use a combination of these entry methods for the
non-dropped-down state.
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
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
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.


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)
It is extremely old code


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.


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
Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Riley | last post by:
The date fields being saved by a VB program were being saved as #2003-11-22#. For reasons unknown to me these dates began to be saved as "11/22/2003" All of these dates were made dates with the...
7
by: Alistair | last post by:
diary_date = request.form("diary_date") - (from a populated drop down list) strSQL = "SELECT saz_title, saz_text from saz_details where saz_date =#" & diary_date & "#" a response.write...
5
by: PW | last post by:
<rant> Sorry guys, but I just have to whinge. Dates in ASP are a total pain in the butt! I seem to get caught out so many times. I realise its my own fault, but going from the posts in this...
10
by: Colin Steadman | last post by:
I'm a stupid ASP programmer and I dont do Javascript (except for very simple tasks anyway), and I'm in a bit of a predicament. I've used a javascript table sorting script from here: ...
1
by: Don Sealer | last post by:
I have a report that includes 5 different subreports. I'd like to be able to open this report using a date function (Start Date and End Date). I'd like all five subreports to show the data from...
2
by: Rachel Suddeth | last post by:
Is there a way to have the non-selectable dates (those before MinDate and after MaxDate) draw differently so my users can see right away what dates aren't allowed? I'm not seeing it... ...
12
by: Dixie | last post by:
I am trying to calculate the number of workdays between two dates with regards to holidays as well. I have used Arvin Meyer's code on the Access Web, but as I am in Australia and my date format is...
1
by: pitfour.ferguson | last post by:
My dbase has the start date and end date of each visit. How can I ask Access to list the day of the week of the start (easy), end (easy) and, more importantly, the dates of the visit itself - ie...
7
by: evilcowstare via AccessMonster.com | last post by:
Hi, I have searched the forum for answers on this and to be honest as a novice I find it a bit confusing so apologies if it is simple. There are some searches that I want to apply to my database....
2
by: Jim Carlock | last post by:
(1) Does PHP provide any way to handle dates prior to 1980? I know there's problems with Microsoft Windows NT and all Windows NT operating systems will allow a date prior to 1980 to be placed...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.