Verify DATE

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • H4nZ83
    New Member
    • Dec 2007
    • 5

    Verify DATE

    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
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Hi,

    Try this :

    [code=vb]
    Dim MyDays As Integer
    Dim MyDate As Date
    MyDate = DateSerial(Val( txtyear.Text), Val(txtmonth.Te xt),1)
    MyDays = DateDiff("d", MyDate, DateAdd("m", 1, MyDate))
    MsgBox "Number of Days " & MyDays
    [/code]

    NOTE: NEVER USE "YEAR" AND "MONTH" as control or variable names...they are keywords/Functions of VBA.DAteTime

    REgards
    Veena

    Comment

    Working...