By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,805 Members | 1,427 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,805 IT Pros & Developers. It's quick & easy.

Verify DATE

H4nZ83
P: 5
I Have a problem, i want to make a function that check if a month is 31 or 30 or 29 day, how can i make that function??

or is there any built in function i vb that can make it simpler??

i use this kind of code

if isdate("31/" & month.text & "/" & year.text) then
dayofmonth=31
elseif isdate("30/" & month.text & "/" & year.text) then dayofmonth=30
elseif isdate("29/" & month.text & "/" & year.text) then dayofmonth=29
elseif isdate("28/" & month.text & "/" & year.text) then dayofmonth=28
May 27 '08 #1
Share this Question
Share on Google+
1 Reply


QVeen72
Expert 100+
P: 1,445
Hi,

Try this :

Expand|Select|Wrap|Line Numbers
  1. Dim MyDays As Integer
  2. Dim MyDate As Date
  3. MyDate = DateSerial(Val(txtyear.Text), Val(txtmonth.Text),1)
  4. MyDays = DateDiff("d", MyDate, DateAdd("m", 1, MyDate))
  5. MsgBox "Number of Days " & MyDays
  6.  
NOTE: NEVER USE "YEAR" AND "MONTH" as control or variable names...they are keywords/Functions of VBA.DAteTime

REgards
Veena
May 27 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.