Results 1 to 2 of 2

Thread: help!!!!!

  1. #1
    Join Date
    Mar 2002
    Location
    malaysia
    Posts
    9

    Unanswered: help!!!!!

    i got a problem that checking the date for credit card.
    my format is mm/dd/yyyy. but everytime i key in correct month but incorrect date, it will pop up error message"invalid month!" but i already set that if the month is more than 12, then the message will pop up, y?
    here are my code:

    Private Sub cmd_summit_Click()
    Dim month As Date, day As Date, year As Date
    Dim month_result As Date, day_result As Date, year_result As Date
    month = Val(txt_month.Text)
    day = Val(txt_day.Text)
    year = Val(txt_year.Text)

    month_result = month1(month)
    day_result = day1(day, month_result)
    year_result = year1(day_result, month_result, year)

    Call MsgBox("Thank you for Purchasing our product!", , "The Online Shopper")

    End Sub
    Private Function month1(m As Date) As Date
    If m > 12 Or IsNumeric(m) = False Then
    Call MsgBox("Invalid Month!", , "The Online Shopper")
    End If

    If m = 1 Or m = 3 Or m = 5 Or m = 7 Or m = 8 Or m = 10 Or m = 12 Then
    month1 = 31
    End If

    If m = 4 Or m = 6 Or m = 9 Or m = 11 Then
    month1 = 30
    End If
    End Function

    Private Function day1(d As Date, m As Date)
    If d > m Then
    Call MsgBox("Invalid date!")
    Else
    day1 = d
    End If
    End Function

    Private Function year1(d As Date, m As Date, y As Date)
    If y < 2002 Then
    Call MsgBox("Your credit card have been expired", , "The Online Shopper")
    End If

    If y = 2002 And d = 16 And m = 4 Then
    Call MsgBox("Your credit card have been expired", , "The Online Shopper")
    End If
    If y > 2002 Then
    year1 = y
    End If
    End Function

  2. #2
    Join Date
    Mar 2002
    Location
    Santos - SP - Brazil
    Posts
    13
    Hi kinki_ngmy,

    You are using Date variable like Integer variable, try to replace all Date declaration for Integer declaration and after that review your program.
    Ok?


    Regards,
    Rafael

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •