If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > help!!!!!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-11-02, 12:22
kinki_ngmy kinki_ngmy is offline
Registered User
 
Join Date: Mar 2002
Location: malaysia
Posts: 9
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
Reply With Quote
  #2 (permalink)  
Old 04-11-02, 14:53
Rafael_Machado Rafael_Machado is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On