Page 1 of 2

30-Day Trial Feature

Posted: Wed Aug 19, 2009 8:25 pm
by CodenStuff
Hello,

Ive got a trial feature for you should anyone need it for your application. It works by using the "Date" and heres how it works:

Image

When someone runs your application for the first time it will grab the current date and add '30' days to it and then store this date. The user can run your application as much as they want for 30 days. If they run the application after 30+ days then it will ask for an activation key, if they dont enter a key or if the key is wrong then the application will not start untill the correct key is entered. They can also activate the program before the end of the 30 day trial.

You can select how many days the trial should run for and the activation key required.

This is how to make it:

Start a new project
Place a button on the form (this will be the activation button)

Go into Project > Project Properties

Now enter the following 2 settings in the 'Settings' tab

apptrial - with a value of "1"
trialcode - leave this value blank

Then add this code to your project:
Code: Select all
Public Class Form1
    'THIS ALLOWS ACTIVATION BEFORE 30 DAY TRIAL IS UP
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim trialkey = InputBox("Please enter your activation key:", "Activation")
        If trialkey = "ABCD123" Then
            My.Settings.trialcode = "ABCD123"
            My.Settings.Save()
        End If
    End Sub
    'THIS CHECKS IF THE PROGRAM IS ACTIVATED OR STILL IN TRIAL WHEN RUN
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim tcode = Convert.ToString(My.Settings.trialcode)
        If (tcode = "ABCD123") Then
            Button1.Visible = False
        Else
            isittrial()
        End If
    End Sub
    'THIS CHECKS IF ITS FIRST TIME BEING USED AND IF THE 30 DAY TRIAL HAS EXPIRED
    Private Sub isittrial()
        Dim trialtime As Date = Now
        Dim currentdatetime As Date = Now
        trialtime = trialtime.AddDays(30) 'SET THIS TO HOWEVER MANY DAYS YOU WANT THE TRIAL TO RUN FOR
        Dim ttime = Convert.ToString(My.Settings.apptrial)
        If (ttime = "1") Then
            My.Settings.trialcode = trialtime
            My.Settings.apptrial = "0"
            My.Settings.Save()
        End If
        If (currentdatetime > trialtime) Then
            Dim trialkey = InputBox("Your trial as expired.  Please enter your activation key:", "Activation")
            If trialkey = "ABCD123" Then
                My.Settings.trialcode = "ABCD123"
                My.Settings.Save()
            Else
                Me.Close()
            End If
        End If
    End Sub
End Class
Change the code "ABCD123" to whatever you want the activation key to be and if you want to change how many days the trial should run, just change this piece of code with the number of days:
Code: Select all
trialtime = trialtime.AddDays(30)
And thats it :D . Compile and run!

It would be very easy to integrate this code to any of your current or future applications as it only uses one button and the code is very short ;) .

Source-Code:
TrialActivation.zip

Thank you and happy coding.

Re: 30-Day Trial Feature

Posted: Wed Aug 19, 2009 10:41 pm
by hungryhounduk
Hi
Cool 8-)
Another good Straight to the point bit of Coding cooll;

Re: 30-Day Trial Feature

Posted: Fri Sep 18, 2009 5:49 pm
by CodemaN
thankssssssssssssss man!!!!!!!!!!!!!!!!!!!11

Re: 30-Day Trial Feature

Posted: Thu Oct 29, 2009 7:49 pm
by Doctorfrost
good program, this is great for people offering a trial version of the application.

If i succeed in my program, im sure to use this.
Thanks :)

Re: 30-Day Trial Feature

Posted: Sun Nov 01, 2009 12:49 am
by Robby
Cool nice application.

But sometimes people can nchange there date back to the date they got their program so i dont know it might not be affective if they change their date back.


I have used this for one of my programs and ty :)


Robby1998

Re: 30-Day Trial Feature

Posted: Sun Nov 01, 2009 4:34 am
by GoodGuy17
If this works out correctly for me, I'm going to put it in my VOS!

Re: 30-Day Trial Feature

Posted: Thu Sep 02, 2010 2:18 pm
by Codex
I agree with Dummy1912, maybe have a file online and add "1" everyday its run or something like that ?

Re: 30-Day Trial Feature

Posted: Thu Sep 02, 2010 2:35 pm
by Dummy1912
i don't like this way
Code: Select all
My.Settings.
because if you are really good with your pc and know a little of it
you can easely find that file and delete it.

so there you have 30 days again :(

Dummy1912

Re: 30-Day Trial Feature

Posted: Thu Sep 02, 2010 2:49 pm
by Axel
Dummy1912 wrote:
i don't like this way
Code: Select all
My.Settings.
because if you are really good with your pc and know a little of it
you can easely find that file and delete it.

so there you have 30 days again :(

Dummy1912
Solutions :

1)if the application.setting file is missing then the application would shutdown (or return the trail value to 0)
2)write a registry key ( but you can deny it with spybot...)
3)the application settings could also be stored on your application i think

Re: 30-Day Trial Feature

Posted: Sun Oct 31, 2010 9:07 am
by Danny
it's great clapper;