08-05-2011, 09:36 PM
A little while ago I posted a video tutorial on how to make your application a 30 day trial. Well, after reviewing that video I realized that the code was long obsolete. So here is a new code.
[code2=vbnet]'This variable, trialLength is the number of days you want your free trial (or paid) to last.
Dim trialLength As Integer = 7
If My.Settings.startdate.Year = 1 Then
'Date has not yet been set, set it for today
My.Settings.startdate = My.Computer.Clock.LocalTime
Else
'Date has already been set, check for # days
Dim ts As New TimeSpan(-trialLength, 0, 0, 0, 0)
If My.Settings.startdate.Subtract(My.Computer.Clock.LocalTime) <= ts Then
'This part of the code occurs if the trial is finished
MsgBox("7 Day trial ended!")
Else
'Trial has not yet ended
MsgBox("You're good.")
End If
End If[/code2]
So simply adjust the trialLength variable to how many days you want your trial to last, and put this into your form load sub!
[code2=vbnet]'This variable, trialLength is the number of days you want your free trial (or paid) to last.
Dim trialLength As Integer = 7
If My.Settings.startdate.Year = 1 Then
'Date has not yet been set, set it for today
My.Settings.startdate = My.Computer.Clock.LocalTime
Else
'Date has already been set, check for # days
Dim ts As New TimeSpan(-trialLength, 0, 0, 0, 0)
If My.Settings.startdate.Subtract(My.Computer.Clock.LocalTime) <= ts Then
'This part of the code occurs if the trial is finished
MsgBox("7 Day trial ended!")
Else
'Trial has not yet ended
MsgBox("You're good.")
End If
End If[/code2]
So simply adjust the trialLength variable to how many days you want your trial to last, and put this into your form load sub!