Visual basic code to setup your program to expire after 30 days

You could check into the FirstRun property, and somehow save that, and check it each time to program is run by using DateDiff.

JD69 0 Newbie Poster 13 Years Ago i dont follow. do u have a sample code? nytro 0 Newbie Poster 13 Years Ago

You can write the code to count from the day of first run to 30 days and just use a simple message box to display that the program is out of date and needs update. This way,you can create another form that will accept some serial numbers to update the program so that it will continue for another 30 days and so on.

betabasic 0 Light Poster 13 Years Ago

you can also save a record to the registry. write a date of first run there.
then every time your program starts,
It checks the record you saved in the registry to find out if the 30days trial has finished. The only problem in this type of licensing is when your client knows where you save that record. Another way is to use licensing softwares.
But you need to pay for that software. I dont know if there's free versions.
try Google search.

nytro 0 Newbie Poster 13 Years Ago

This is a nice codes i generated myself to solve this problem. You can study and look at what i did and improve upon it. @@@ Try to copy and put into a blank form and debug it to see what happens but you need to change the day on your system date to the number indicated as 13. for the trial period to execute. ###

Public Class Form1 Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing If MsgBox("Are you sure to exit", MsgBoxStyle.YesNo, "Exit") = MsgBoxResult.No Then e.Cancel = True End If End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load fade_in() If Date.Now.Day <> 13 Then MsgBox("Your application is out-of-date and needs update", MsgBoxStyle.Information, "Trial mode") Me.Close() Else Me.Show() End If End Sub 'Fade in Public Sub fade_in() For FadeIn = 0.0 To 1.1 Step 0.1 Me.Opacity = FadeIn Me.Refresh() Threading.Thread.Sleep(100) Next End Sub 'Fade out: Public Sub fade_out() For FadeOut = 90 To 10 Step -10 Me.Opacity = FadeOut / 100 Me.Refresh() Threading.Thread.Sleep(50) Next End Sub End Class 
Edited 11 Years Ago by Reverend Jim because: reformatted code JD69 0 Newbie Poster 13 Years Ago

i appreciate your help but i need it to stop the user for using the program. I basically want the user to be prompted for a password to launch the application and after 30 days that password stops working and they wont be allowed access Can you guys help with this? Thanks

Xcelled194 28 Junior Poster in Training 13 Years Ago This is untested:
'Make a new form, put this code in it, and set it as your startup form 'Also, make a new user setting of the type "date" called Expiration_Date Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If My.Application.Deployment.IsFirstRun Then My.Settings.Expiration_Date = Now.Date My.Settings.Save() End If If DateDiff(DateInterval.Day, Now, My.Settings.Expiration_Date) > 30 Then '30 is the expiration date Dim Response As String = "~" While Response <> "Password here" And Response <> Nothing Response = InputBox("The 30 day trial is up! Please enter a password to continue using this software!", "Trial") End While If Response = Nothing Then End 'A crude, but effective, way of forcing a close End If Me.Hide() Mainform.show() 'If it passes all the tests, start the main program End Sub End Class
zinnqu 7 Junior Poster in Training 13 Years Ago

This is not tested and may need debugging but: Here is an example that creates settings then handles them, adjust the code to work for your program and/or handle the dates like

# Public Function DateGood(NumDays As Integer) As Boolean 'The purpose of this module is to allow you to place a time 'limit on the unregistered use of your shareware application. 'This module can not be defeated by rolling back the system clock. 'Simply call the DateGood function when your application is first 'loading, passing it the number of days it can be used without 'registering. ' 'Ex: If DateGood(30)=False Then ' CrippleApplication ' End if 'Register Parameters: ' CRD: Current Run Date ' LRD: Last Run Date ' FRD: First Run Date Dim TmpCRD As Date Dim TmpLRD As Date Dim TmpFRD As Date TmpCRD = Format(Now, "m/d/yy") TmpLRD = GetSetting(App.EXEName, "Param", "LRD", "1/1/2000") TmpFRD = GetSetting(App.EXEName, "Param", "FRD", "1/1/2000") DateGood = False 'If this is the applications first load, write initial settings 'to the register If TmpLRD = "1/1/2000" Then SaveSetting App.EXEName, "Param", "LRD", TmpCRD SaveSetting App.EXEName, "Param", "FRD", TmpCRD End If 'Read LRD and FRD from register TmpLRD = GetSetting(App.EXEName, "Param", "LRD", "1/1/2000") TmpFRD = GetSetting(App.EXEName, "Param", "FRD", "1/1/2000") If TmpFRD > TmpCRD Then 'System clock rolled back DateGood = False ElseIf Now > DateAdd("d", NumDays, TmpFRD) Then 'Expiration expired DateGood = False ElseIf TmpCRD > TmpLRD Then 'Everything OK write New LRD date SaveSetting App.EXEName, "Param", "LRD", TmpCRD DateGood = True ElseIf TmpCRD = Format(TmpLRD, "m/d/yy") Then DateGood = True Else DateGood = False End If End Function 'Usage Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Set timer and test If Not DateGood(30) Then MsgBox("Trial Period Expired!", vbExclamation, "Unregistered application") Me.Hide() 'Hide if not Else Me.Show() 'Show if good End If End Sub