Hi to every one I'm creating a software but I have to expire it
After 3days I'm am writing this code but it is not working

if date(now) >=date(29/9/2011) then 
    Msgbox "the software has been expired and unload Me
End if

Is this true

Recommended Answers

All 6 Replies

you can write this

If Format(Now, "mm/dd/YYYY") >= 29/9/2011 Then
    Msgbox "the software has been expired"
End if
unload me
commented: Did you even test this? My guess is "no". -1

Use this:

If DateDiff("d", Now, "9/29/2011") = 0 Then
    MsgBox "the software has been expired."
    Unload Me
End If

ya I test it and it work well. I don't understand what you want to say................and why you give me -1 !!!

ya I test it and it work well. I don't understand what you want to say................and why you give me -1 !!!

Here is my assessment of your "solution".

1. No quotes around what I assume you meant to be a date literal.
2. Trying to compare a set of "number divided by number divided by number" to a formatted date (which would be a number to a string...bad).
3. Logic error by not including the "unload" (supposed to be only on mismatch...) as part of the IF...THEN...ELSE.

Frankly, I don't think you really tested your solution. At least not in any version of VB I've ever worked with. If you had tested any sort of boundary condition (say, for instance, with some other date literal) you would have immediately discovered that your solution was completely incorrect.

People come to this site for guidance and help. Offering snippets of code that have not been tested and are demonstrably incorrect degrade the quality of the site overall. And, to call me out publicly for pointing out that your "solution" is wrong is frankly casting the gauntlet.

I have little patience with people who offer untested or poorly tested solutions. If you have a disagreement with my assessment, feel free to send me a personal message to prove I am wrong. If you can prove you are correct I will gladly retract ON THIS THREAD and apologize. Otherwise, I suggest that you actually test your solutions before you post.

commented: Thanks a lot. +6
commented: agree +13

If DateDiff("d", Now, "9/2/2011") = 0 Then
MsgBox "the software has been expired."
Unload Me
End If
(not working)

If DateDiff("d", Now, "9/2/2011") =< 0 Then
MsgBox "the software has been expired."
Unload Me
End If
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.