Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 5th, 2004, 02:54 AM
Authorized User
 
Join Date: Sep 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Right date?

Hi, do you know how could I check that the entried date is right?

I have three combo box: day - month - year
I would like to validate that the day is right with the month.

Do you now a fast way to validate?

Thanks

 
Old October 29th, 2004, 09:58 AM
Authorized User
 
Join Date: Oct 2004
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to shattered Send a message via Yahoo to shattered
Default

Pass the value of the combo boxes (I've used cell locations in this example but the principle is the same).

Sub CheckDate()
    Dim myDate As Date
    On Error Resume Next
    sDay = Cells(10, 2).Value
    sMon = Cells(10, 3).Value
    sYear = Cells(10, 4).Value
    myDate = sDay & "/" & sMon & "/" & sYear
    If Err = 13 Then
        MsgBox "Date is invalid"
    Else
        MsgBox "Date is valid"
    End If
End Sub






Similar Threads
Thread Thread Starter Forum Replies Last Post
Show Images from Start Date thru Date istcomnet Classic ASP Basics 2 May 23rd, 2008 07:12 AM
How to find a date range between another date rang tayvonne Access 2 August 3rd, 2006 09:50 AM
copy date values between date controls Alcapone Javascript How-To 1 April 13th, 2006 03:13 AM
DTS Import ( Date string to Date field) gfowajuh SQL Server 2000 1 September 30th, 2003 06:28 AM
Convert String Date to Date for a SQL Query tdaustin Classic ASP Basics 4 July 7th, 2003 06:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.