Date Validation And Month
please some one tell me how to know that the date entered in a Textbox is valid or not.
i m using this format 3/08/2008
next question is how to know how many days are there in a given month and how to start a next month when we close the current month
Re: Date Validation And Month
isdate(text1.text)
there may well be a better way to get the number of days in a month, but this should work
Code:
msgbox day(dateadd("d",-1,dateadd("m",1,"1/" & format(text1, "mmm") & "/" & year(text1))))
Re: Date Validation And Month
I would use this:
Code:
myDate = Date '-- or whatever date
MsgBox Day(DateSerial(Year(myDate), Month(myDate) + 1, 0))
Re: Date Validation And Month
It would be a much better idea (in terms of amount of code, reliability, etc) to not use a Textbox at all, but a proper date control instead - like the ones shown in the article What controls can I use to input a date/time? from our Classic VB FAQs (in the FAQ forum, which is shown near the top of our home page)
You may also find it useful to read the FAQ article Why are my dates not working properly?, which explains things like the big differences between a Date and a String.