Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
YH YH is offline
external usenet poster
 
Posts: 18
Default Validate user input with specific date format

I am new to VBA and not familiar with the syntax. Can someone help me with
the following task?

I have user provide me a date using inputbox(), and I want to verify if the
input date meets the following requirements. If yes, accept the input. If
not, reject the input and loop back to ask for input again.

** Requirements:
1) The input date has to be in mm/dd/yyyy or m/d/yyyy (1/1/2006 for example)
format. If user enters single digit for month and day such as 1/1/2006, the
script will
accept the input and reformat it to mm/dd/yyyy (01/01/20006 for example).

2) The delimiter has to be "/". All other delimiters will be rejected.

3) Reject input if condition 1) and 2) above are not met. Loop back to ask
for user input again.

Any help is greatly appreciated. Thanks!

YH

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default Validate user input with specific date format


YH wrote:
I am new to VBA and not familiar with the syntax. Can someone help me with
the following task?

I have user provide me a date using inputbox(), and I want to verify if the
input date meets the following requirements. If yes, accept the input. If
not, reject the input and loop back to ask for input again.

** Requirements:
1) The input date has to be in mm/dd/yyyy or m/d/yyyy (1/1/2006 for example)
format. If user enters single digit for month and day such as 1/1/2006, the
script will
accept the input and reformat it to mm/dd/yyyy (01/01/20006 for example).

2) The delimiter has to be "/". All other delimiters will be rejected.

3) Reject input if condition 1) and 2) above are not met. Loop back to ask
for user input again.

Any help is greatly appreciated. Thanks!

YH

just and idea: rather than user a input box..maybe use the calendar
control on a form where the user just clicks on the date..then the date
is format correct in the output and it eliminates the need for the
error checking.

  #3   Report Post  
Posted to microsoft.public.excel.programming
YH YH is offline
external usenet poster
 
Posts: 18
Default Validate user input with specific date format

How do I do calendar control?

Would appreciate if someone can share how to code the error checking per
requirements...

Thanks,

YH

"stevebriz" wrote:


YH wrote:
I am new to VBA and not familiar with the syntax. Can someone help me with
the following task?

I have user provide me a date using inputbox(), and I want to verify if the
input date meets the following requirements. If yes, accept the input. If
not, reject the input and loop back to ask for input again.

** Requirements:
1) The input date has to be in mm/dd/yyyy or m/d/yyyy (1/1/2006 for example)
format. If user enters single digit for month and day such as 1/1/2006, the
script will
accept the input and reformat it to mm/dd/yyyy (01/01/20006 for example).

2) The delimiter has to be "/". All other delimiters will be rejected.

3) Reject input if condition 1) and 2) above are not met. Loop back to ask
for user input again.

Any help is greatly appreciated. Thanks!

YH

just and idea: rather than user a input box..maybe use the calendar
control on a form where the user just clicks on the date..then the date
is format correct in the output and it eliminates the need for the
error checking.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Validate user input with specific date format

Ron de Bruin has some tips/links at:
http://www.rondebruin.nl/calendar.htm

ps. I don't think you'll be able enforce your rule that data must be entered in
mdy order. If the user enters 03/06/2006, your program may not use what the
user really intended (June 3, 2006 or March 6, 2006???).

You can assume that they did it correct or tell them what date you're going to
use (kind of an "Are you sure you want to use March 6, 2006" prompt)--or just
use that calendar control and remove all doubt.

YH wrote:

How do I do calendar control?

Would appreciate if someone can share how to code the error checking per
requirements...

Thanks,

YH

"stevebriz" wrote:


YH wrote:
I am new to VBA and not familiar with the syntax. Can someone help me with
the following task?

I have user provide me a date using inputbox(), and I want to verify if the
input date meets the following requirements. If yes, accept the input. If
not, reject the input and loop back to ask for input again.

** Requirements:
1) The input date has to be in mm/dd/yyyy or m/d/yyyy (1/1/2006 for example)
format. If user enters single digit for month and day such as 1/1/2006, the
script will
accept the input and reformat it to mm/dd/yyyy (01/01/20006 for example).

2) The delimiter has to be "/". All other delimiters will be rejected.

3) Reject input if condition 1) and 2) above are not met. Loop back to ask
for user input again.

Any help is greatly appreciated. Thanks!

YH

just and idea: rather than user a input box..maybe use the calendar
control on a form where the user just clicks on the date..then the date
is format correct in the output and it eliminates the need for the
error checking.



--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default Validate user input with specific date format

For your first question.
This should help
http://www.fontstuff.com/vba/vbatut07.htm



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Restrict-Filter-Limit-Validate user input in Excel Dr. Thom Excel Discussion (Misc queries) 0 January 22nd 06 08:06 PM
Input Box Help - Validate Date Format Tbal[_5_] Excel Programming 1 September 6th 05 09:13 PM
TEXTBOX - VALIDATE DATE INPUT Steve_G Excel Programming 3 June 12th 05 04:59 AM
how to format a date/validate for a text box entry on a user form Tom Ogilvy Excel Programming 3 June 1st 05 05:06 PM
How do I make a cell date specific to input a value on a specific. ebuzz13 Excel Discussion (Misc queries) 1 January 18th 05 05:53 PM


All times are GMT +1. The time now is 10:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"