BP Forums
Improved program trial - Printable Version

+- BP Forums (https://bpforums.info)
+-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55)
+--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56)
+---- Forum: VB.NET (Visual Basic 2010/2008) (https://bpforums.info/forumdisplay.php?fid=8)
+----- Forum: Code Snippets (https://bpforums.info/forumdisplay.php?fid=18)
+----- Thread: Improved program trial (/showthread.php?tid=381)



Improved program trial - brandonio21 - 08-05-2011

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!


Re: Improved program trial - openeXpressions - 11-22-2011

It's also a good idea to save this in the registry as well.


Re: Improved program trial - AnchoredFTW - 12-27-2011

openeXpressions Wrote:It's also a good idea to save this in the registry as well.

Not really as it can be easily edited using Regedit


Re: Improved program trial - brandonio21 - 12-27-2011

AnchoredFTW Wrote:Not really as it can be easily edited using Regedit

This is true; however, alot of people do not know how to use RegEdit.


Re: Improved program trial - zmanalpha - 12-28-2011

Thank You For This. It Will Help Alot!