• (2 Pages)
  • +
  • 1
  • 2

Trial Period How to add a two week trial to your application Rate Topic: -----

#1 Bort  Icon User is offline

  • Ill-informed Mongoloid
  • member icon

Reputation: 404
  • View blog
  • Posts: 2,983
  • Joined: 18-September 06

Posted 01 October 2008 - 08:10 AM

This tutorial will teach you how to add a trial period to your program, allowing you to offer potential customers a chance to test out your application before buying it. Although this sounds very complicated, it is actually very simple. For the purposes of this tutorial, I will be using Visual Basic 2008 Express Edition, but there is no reason why this will not work in a 2005 version of Visual Studio.

First of all, you will need to declare the required variables. For these you will need the following:

2 Date type variables - I named them dteStartDate and dteLastStart. dteStartDate is when the trial program is first installed and ran, dteLastStart is the date the program was last ran.

2 Boolean type variables - blnEnabled and blnFirstTime. blnEnabled keeps track of if the trial is still active or should be disabled. blnFirstTime will come into effect into part 2 of the tutorial (Adding a registry key to stop the trial being ran more than once), but I need more study before I can do that part.

1 Long type variable - lngTimeLeft. Keeps track of how many days remain in the trial.

1 Integer type variable - intTime. Keeps an eye out for people making changes to the system clock to extend the trial.

At this point, you should also set intTime to '1', blnEnabled to 'True', and make sure dteStartDate is assigned the date the program is first ran. Then add a statement telling your application to save it's settings when the program is closed.

		Dim intTime As Integer = 1
		Dim dteLastStart, dteStartDate As Date
		Dim blnFirstTime, blnEnabled As Boolean
		Dim lngTimeLeft As Long
		
		blnEnabled = True
		If dteStartDate = Nothing Then
			dteStartDate = Now
		End If

		My.Application.SaveMySettingsOnExit = True



Our next step is to add a few lines of code designed to stop people changing the system clock to extend the trial. Eventually, this will be coupled with a registry entry to disallow multiple installs of the demo, but as I have already mentioned, I need to look into that a bit further before I put anything on here.

		If DateDiff(DateInterval.Day, dteLastStart, Now) < 0 Then
			'First clock change
			If intTime = 1 Then
				MsgBox("FRED has detected that you have changed your system date to an earlier date" & vbCrLf & "As FRED has built-in security," & vbCrLf & "FRED will only run until the next intTime you change your system date", MsgBoxStyle.OkOnly Or MsgBoxStyle.Exclamation, "System Date Changed")
				intTime = 2
			ElseIf intTime = 2 Then
				'Second clock change
				blnEnabled = False
				MsgBox("FRED has detected that you have changed your system date to an earlier date" & vbCrLf & "As this is the second warning, FRED will now be disabled", MsgBoxStyle.OkOnly Or MsgBoxStyle.Exclamation, "System Date Changed")
			End If
			'disables app
			If blnEnabled = False Then
				If MsgBox("FRED is disabled", MsgBoxStyle.OkOnly Or MsgBoxStyle.Information, "Disabled") = MsgBoxResult.Ok Then
					For Each form As Form In My.Application.OpenForms
						form.Close()
					Next
				End If
			End If
		End If



So, first of all, check the number of days between the date the application was last ran, and today's date according to the system clock. If today's date is before the date the application was last ran, then the program will issue a warning, basically saying 'We know you changed your clock to an earlier date. Because this is the first time you've done this, we'll be nice and give you a warning. Don't do it again". Then it changes the intTime variable to 2 in case they try this trick a second time. This code can easily be changed to give more or fewer warnings before disabling the trial. All you will need to do is move the line 'blnEnabled = False' to another If statement, and remember to keep adding 1 to intTime for every warning you wish to give the user.

For this example, we only give the 1 warning, so if the user tries changing the system clock again, it will disable the application and givbe a message basically saying 'We warned you". Then it offers a second messagebox telling the user it has been disabled, then closes any open forms.

Finally, the last piece of code we need is that which disables the application at the end of the trial. This part can be modified to change the length of the trial to whatever you see fit. Just change the '14' (all 3 of them in this piece of code) to however many days you want the user to trial your application.

		If DateDiff(DateInterval.Day, dteStartDate, Now) > 14 Then
			blnEnabled = False
			If blnEnabled = False Then
				If MsgBox("FRED has reached the end of it's trial.", MsgBoxStyle.OkOnly Or MsgBoxStyle.Information, "Trial Ended") = MsgBoxResult.Ok Then
					'Close all open forms
					For Each form As Form In My.Application.OpenForms
						form.Close()
					Next
				End If
			End If
		End If
		dteLastStart = Now
		If blnFirstTime = True Then
			blnFirstTime = False
		End If
		'Saves variable settings
		My.Settings.Save()

		lngTimeLeft = 14 - (DateDiff(DateInterval.Day, dteStartDate, Now))

		MsgBox("This is a 14-day trial version." & vbCrLf & "You have " & CStr(lngTimeLeft) & " days left.", MsgBoxStyle.OkOnly, "FRED Trial")



The very end records the date the program is ran, saves the settings, and gives a messagebox telling the user how many days are left.

If you have any questions or comments about this, please post them here.

Happy coding,
Bort

Is This A Good Question/Topic? 0
  • +

Replies To: Trial Period

#2 RodgerB  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 66
  • View blog
  • Posts: 2,284
  • Joined: 21-September 07

Posted 04 October 2008 - 04:11 PM

If the attacker wants to extend his or her trial period, all he/she needs to do is edit the start date in the registry, correct?

May I suggest the use of encryption?
Was This Post Helpful? 0
  • +
  • -

#3 Bort  Icon User is offline

  • Ill-informed Mongoloid
  • member icon

Reputation: 404
  • View blog
  • Posts: 2,983
  • Joined: 18-September 06

Posted 06 October 2008 - 01:55 AM

Encryption is probably a good idea. Unfortunately, I would not know how to implement it.

Perhaps you can point me in the direction of something I can take a look at about encryption?

Thanks,
Bort
Was This Post Helpful? 0
  • +
  • -

#4 JohnorSky  Icon User is offline

  • D.I.C Head

Reputation: -5
  • View blog
  • Posts: 137
  • Joined: 02-September 08

Posted 08 October 2008 - 02:45 PM

Could they take the program they have and make a copy of it and run it and delete the other program and it would run as if the program never expired?

OR will this user not be able to run any copies of the program at any time after the period is over?
Was This Post Helpful? 0
  • +
  • -

#5 Bort  Icon User is offline

  • Ill-informed Mongoloid
  • member icon

Reputation: 404
  • View blog
  • Posts: 2,983
  • Joined: 18-September 06

Posted 09 October 2008 - 01:27 AM

At the moment, they could do that. I'm currently working on another two tutorials to help prevent this and generally make it more secure. The first is about encryption, and the second is how to add, edit, and remove registry entries, so between them, they should be able to make a trial version of a product fairly safe from tampering.

I have been looking at encryption over the last few days, and it is actually surprisingly simple. I will put a link to it from here when it is ready.

Also, having the registry entries means that when someone with the trial version of a program buys the full version, we can simply add a few lines of code to the full version which will edit (or remove) the registry entry.

EDIT:
Link to Encryption Tutorial:
http://www.dreaminco...wtopic66882.htm

This post has been edited by Bort: 09 October 2008 - 08:08 AM

Was This Post Helpful? 0
  • +
  • -

#6 JohnorSky  Icon User is offline

  • D.I.C Head

Reputation: -5
  • View blog
  • Posts: 137
  • Joined: 02-September 08

Posted 09 October 2008 - 12:21 PM

^Sounds cool, I'll be reading your guides. ;P
Was This Post Helpful? 0
  • +
  • -

#7 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9213
  • View blog
  • Posts: 34,599
  • Joined: 12-June 08

Posted 25 October 2008 - 11:13 AM

Just an FYI.. the my.settings data is saved not in the registry per say but at this path:
C:\Documents and Settings\<user name>\Local Settings\Apps and down from there. We use it all the time at work and if something gets munged up we have users delete the data below that path for what ever project they are calling in on. Essentially it would short circuit your logic there and treat it as if it's the first time using it.

No big whoop - you average user wouldn't know about it.. but it's there.
Was This Post Helpful? 0
  • +
  • -

#8 Bort  Icon User is offline

  • Ill-informed Mongoloid
  • member icon

Reputation: 404
  • View blog
  • Posts: 2,983
  • Joined: 18-September 06

Posted 28 October 2008 - 03:27 AM

View Postmodi123_1, on 25 Oct, 2008 - 11:13 AM, said:

Just an FYI.. the my.settings data is saved not in the registry per say but at this path:
C:\Documents and Settings\<user name>\Local Settings\Apps and down from there. We use it all the time at work and if something gets munged up we have users delete the data below that path for what ever project they are calling in on. Essentially it would short circuit your logic there and treat it as if it's the first time using it.

No big whoop - you average user wouldn't know about it.. but it's there.


Cool, thanks for letting me know. I didn't realise this.
Was This Post Helpful? 0
  • +
  • -

#9 daveofgv  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 06-November 08

Posted 06 November 2008 - 08:06 AM

Just a quick question..... I tried to use it, however, the system does not see date change and count down the days..... Any suggestions???

daveofgv
Was This Post Helpful? 0
  • +
  • -

#10 sureshkvp85  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 6
  • Joined: 07-November 08

Posted 10 November 2008 - 02:07 AM

View PostBort, on 1 Oct, 2008 - 07:10 AM, said:

This tutorial will teach you how to add a trial period to your program, allowing you to offer potential customers a chance to test out your application before buying it. Although this sounds very complicated, it is actually very simple. For the purposes of this tutorial, I will be using Visual Basic 2008 Express Edition, but there is no reason why this will not work in a 2005 version of Visual Studio.

First of all, you will need to declare the required variables. For these you will need the following:

2 Date type variables - I named them dteStartDate and dteLastStart. dteStartDate is when the trial program is first installed and ran, dteLastStart is the date the program was last ran.

2 Boolean type variables - blnEnabled and blnFirstTime. blnEnabled keeps track of if the trial is still active or should be disabled. blnFirstTime will come into effect into part 2 of the tutorial (Adding a registry key to stop the trial being ran more than once), but I need more study before I can do that part.

1 Long type variable - lngTimeLeft. Keeps track of how many days remain in the trial.

1 Integer type variable - intTime. Keeps an eye out for people making changes to the system clock to extend the trial.

At this point, you should also set intTime to '1', blnEnabled to 'True', and make sure dteStartDate is assigned the date the program is first ran. Then add a statement telling your application to save it's settings when the program is closed.

		Dim intTime As Integer = 1
		Dim dteLastStart, dteStartDate As Date
		Dim blnFirstTime, blnEnabled As Boolean
		Dim lngTimeLeft As Long
		
		blnEnabled = True
		If dteStartDate = Nothing Then
			dteStartDate = Now
		End If

		My.Application.SaveMySettingsOnExit = True



Our next step is to add a few lines of code designed to stop people changing the system clock to extend the trial. Eventually, this will be coupled with a registry entry to disallow multiple installs of the demo, but as I have already mentioned, I need to look into that a bit further before I put anything on here.

		If DateDiff(DateInterval.Day, dteLastStart, Now) < 0 Then
			'First clock change
			If intTime = 1 Then
				MsgBox("FRED has detected that you have changed your system date to an earlier date" & vbCrLf & "As FRED has built-in security," & vbCrLf & "FRED will only run until the next intTime you change your system date", MsgBoxStyle.OkOnly Or MsgBoxStyle.Exclamation, "System Date Changed")
				intTime = 2
			ElseIf intTime = 2 Then
				'Second clock change
				blnEnabled = False
				MsgBox("FRED has detected that you have changed your system date to an earlier date" & vbCrLf & "As this is the second warning, FRED will now be disabled", MsgBoxStyle.OkOnly Or MsgBoxStyle.Exclamation, "System Date Changed")
			End If
			'disables app
			If blnEnabled = False Then
				If MsgBox("FRED is disabled", MsgBoxStyle.OkOnly Or MsgBoxStyle.Information, "Disabled") = MsgBoxResult.Ok Then
					For Each form As Form In My.Application.OpenForms
						form.Close()
					Next
				End If
			End If
		End If



So, first of all, check the number of days between the date the application was last ran, and today's date according to the system clock. If today's date is before the date the application was last ran, then the program will issue a warning, basically saying 'We know you changed your clock to an earlier date. Because this is the first time you've done this, we'll be nice and give you a warning. Don't do it again". Then it changes the intTime variable to 2 in case they try this trick a second time. This code can easily be changed to give more or fewer warnings before disabling the trial. All you will need to do is move the line 'blnEnabled = False' to another If statement, and remember to keep adding 1 to intTime for every warning you wish to give the user.

For this example, we only give the 1 warning, so if the user tries changing the system clock again, it will disable the application and givbe a message basically saying 'We warned you". Then it offers a second messagebox telling the user it has been disabled, then closes any open forms.

Finally, the last piece of code we need is that which disables the application at the end of the trial. This part can be modified to change the length of the trial to whatever you see fit. Just change the '14' (all 3 of them in this piece of code) to however many days you want the user to trial your application.

		If DateDiff(DateInterval.Day, dteStartDate, Now) > 14 Then
			blnEnabled = False
			If blnEnabled = False Then
				If MsgBox("FRED has reached the end of it's trial.", MsgBoxStyle.OkOnly Or MsgBoxStyle.Information, "Trial Ended") = MsgBoxResult.Ok Then
					'Close all open forms
					For Each form As Form In My.Application.OpenForms
						form.Close()
					Next
				End If
			End If
		End If
		dteLastStart = Now
		If blnFirstTime = True Then
			blnFirstTime = False
		End If
		'Saves variable settings
		My.Settings.Save()

		lngTimeLeft = 14 - (DateDiff(DateInterval.Day, dteStartDate, Now))

		MsgBox("This is a 14-day trial version." & vbCrLf & "You have " & CStr(lngTimeLeft) & " days left.", MsgBoxStyle.OkOnly, "FRED Trial")



The very end records the date the program is ran, saves the settings, and gives a messagebox telling the user how many days are left.

If you have any questions or comments about this, please post them here.

Happy coding,
Bort

Was This Post Helpful? 0
  • +
  • -

#11 bravo659  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 181
  • Joined: 18-May 08

Posted 17 November 2008 - 07:17 PM

View PostBort, on 1 Oct, 2008 - 07:10 AM, said:

This tutorial will teach you how to add a trial period to your program, allowing you to offer potential customers a chance to test out your application before buying it. Although this sounds very complicated, it is actually very simple. For the purposes of this tutorial, I will be using Visual Basic 2008 Express Edition, but there is no reason why this will not work in a 2005 version of Visual Studio.

First of all, you will need to declare the required variables. For these you will need the following:

2 Date type variables - I named them dteStartDate and dteLastStart. dteStartDate is when the trial program is first installed and ran, dteLastStart is the date the program was last ran.

2 Boolean type variables - blnEnabled and blnFirstTime. blnEnabled keeps track of if the trial is still active or should be disabled. blnFirstTime will come into effect into part 2 of the tutorial (Adding a registry key to stop the trial being ran more than once), but I need more study before I can do that part.

1 Long type variable - lngTimeLeft. Keeps track of how many days remain in the trial.

1 Integer type variable - intTime. Keeps an eye out for people making changes to the system clock to extend the trial.

At this point, you should also set intTime to '1', blnEnabled to 'True', and make sure dteStartDate is assigned the date the program is first ran. Then add a statement telling your application to save it's settings when the program is closed.

		Dim intTime As Integer = 1
		Dim dteLastStart, dteStartDate As Date
		Dim blnFirstTime, blnEnabled As Boolean
		Dim lngTimeLeft As Long
		
		blnEnabled = True
		If dteStartDate = Nothing Then
			dteStartDate = Now
		End If

		My.Application.SaveMySettingsOnExit = True



Our next step is to add a few lines of code designed to stop people changing the system clock to extend the trial. Eventually, this will be coupled with a registry entry to disallow multiple installs of the demo, but as I have already mentioned, I need to look into that a bit further before I put anything on here.

		If DateDiff(DateInterval.Day, dteLastStart, Now) < 0 Then
			'First clock change
			If intTime = 1 Then
				MsgBox("FRED has detected that you have changed your system date to an earlier date" & vbCrLf & "As FRED has built-in security," & vbCrLf & "FRED will only run until the next intTime you change your system date", MsgBoxStyle.OkOnly Or MsgBoxStyle.Exclamation, "System Date Changed")
				intTime = 2
			ElseIf intTime = 2 Then
				'Second clock change
				blnEnabled = False
				MsgBox("FRED has detected that you have changed your system date to an earlier date" & vbCrLf & "As this is the second warning, FRED will now be disabled", MsgBoxStyle.OkOnly Or MsgBoxStyle.Exclamation, "System Date Changed")
			End If
			'disables app
			If blnEnabled = False Then
				If MsgBox("FRED is disabled", MsgBoxStyle.OkOnly Or MsgBoxStyle.Information, "Disabled") = MsgBoxResult.Ok Then
					For Each form As Form In My.Application.OpenForms
						form.Close()
					Next
				End If
			End If
		End If



So, first of all, check the number of days between the date the application was last ran, and today's date according to the system clock. If today's date is before the date the application was last ran, then the program will issue a warning, basically saying 'We know you changed your clock to an earlier date. Because this is the first time you've done this, we'll be nice and give you a warning. Don't do it again". Then it changes the intTime variable to 2 in case they try this trick a second time. This code can easily be changed to give more or fewer warnings before disabling the trial. All you will need to do is move the line 'blnEnabled = False' to another If statement, and remember to keep adding 1 to intTime for every warning you wish to give the user.

For this example, we only give the 1 warning, so if the user tries changing the system clock again, it will disable the application and givbe a message basically saying 'We warned you". Then it offers a second messagebox telling the user it has been disabled, then closes any open forms.

Finally, the last piece of code we need is that which disables the application at the end of the trial. This part can be modified to change the length of the trial to whatever you see fit. Just change the '14' (all 3 of them in this piece of code) to however many days you want the user to trial your application.

		If DateDiff(DateInterval.Day, dteStartDate, Now) > 14 Then
			blnEnabled = False
			If blnEnabled = False Then
				If MsgBox("FRED has reached the end of it's trial.", MsgBoxStyle.OkOnly Or MsgBoxStyle.Information, "Trial Ended") = MsgBoxResult.Ok Then
					'Close all open forms
					For Each form As Form In My.Application.OpenForms
						form.Close()
					Next
				End If
			End If
		End If
		dteLastStart = Now
		If blnFirstTime = True Then
			blnFirstTime = False
		End If
		'Saves variable settings
		My.Settings.Save()

		lngTimeLeft = 14 - (DateDiff(DateInterval.Day, dteStartDate, Now))

		MsgBox("This is a 14-day trial version." & vbCrLf & "You have " & CStr(lngTimeLeft) & " days left.", MsgBoxStyle.OkOnly, "FRED Trial")



The very end records the date the program is ran, saves the settings, and gives a messagebox telling the user how many days are left.

If you have any questions or comments about this, please post them here.

Happy coding,
Bort


[quote]
Hello Bort, how you doing? I like this tutorial and is very handy whenever I create an application that I know I can sell I can also use the trial period code. This is cool. That is why I like programming it is fun. Well easy, I really wouldn't its easy but challenging, my opinion. LOL
However, I like this site I can learn a lot from here. I am currently in college and my last college professor really didn't teach me anything in the advanced class. I study on my own and practice the coding so I can be more fluent and proficient by the time I graduate. I am 50 years old and been a carpenter for over 20 years and due to the construction industry slowing down I decided to change my career to IT/Programming. I like Visual Basic and the making of software windows apps. Thanks for your time making a tutorial I will learn from it. I was looking at the DateDiff which that is what I had to use for the Sql server class for a video store cool snippets to add. Thanks again, Bort. sorry for he long speech.
Was This Post Helpful? 0
  • +
  • -

#12 Rickster090  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 100
  • Joined: 10-January 08

Posted 06 April 2009 - 11:24 AM

this doesn't seem to work for me..

when i change my date forward nothing happens...
Was This Post Helpful? 0
  • +
  • -

#13 mike.nelson  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 10-November 09

Posted 10 November 2009 - 06:53 AM

View PostBort, on 1 Oct, 2008 - 07:10 AM, said:

This tutorial will teach you how to add a trial period to your program, allowing you to offer potential customers a chance to test out your application before buying it. Although this sounds very complicated, it is actually very simple. For the purposes of this tutorial, I will be using Visual Basic 2008 Express Edition, but there is no reason why this will not work in a 2005 version of Visual Studio.

First of all, you will need to declare the required variables. For these you will need the following:

2 Date type variables - I named them dteStartDate and dteLastStart. dteStartDate is when the trial program is first installed and ran, dteLastStart is the date the program was last ran.

2 Boolean type variables - blnEnabled and blnFirstTime. blnEnabled keeps track of if the trial is still active or should be disabled. blnFirstTime will come into effect into part 2 of the tutorial (Adding a registry key to stop the trial being ran more than once), but I need more study before I can do that part.

1 Long type variable - lngTimeLeft. Keeps track of how many days remain in the trial.

1 Integer type variable - intTime. Keeps an eye out for people making changes to the system clock to extend the trial.

At this point, you should also set intTime to '1', blnEnabled to 'True', and make sure dteStartDate is assigned the date the program is first ran. Then add a statement telling your application to save it's settings when the program is closed.

		Dim intTime As Integer = 1
		Dim dteLastStart, dteStartDate As Date
		Dim blnFirstTime, blnEnabled As Boolean
		Dim lngTimeLeft As Long
		
		blnEnabled = True
		If dteStartDate = Nothing Then
			dteStartDate = Now
		End If

		My.Application.SaveMySettingsOnExit = True



Our next step is to add a few lines of code designed to stop people changing the system clock to extend the trial. Eventually, this will be coupled with a registry entry to disallow multiple installs of the demo, but as I have already mentioned, I need to look into that a bit further before I put anything on here.

		If DateDiff(DateInterval.Day, dteLastStart, Now) < 0 Then
			'First clock change
			If intTime = 1 Then
				MsgBox("FRED has detected that you have changed your system date to an earlier date" & vbCrLf & "As FRED has built-in security," & vbCrLf & "FRED will only run until the next intTime you change your system date", MsgBoxStyle.OkOnly Or MsgBoxStyle.Exclamation, "System Date Changed")
				intTime = 2
			ElseIf intTime = 2 Then
				'Second clock change
				blnEnabled = False
				MsgBox("FRED has detected that you have changed your system date to an earlier date" & vbCrLf & "As this is the second warning, FRED will now be disabled", MsgBoxStyle.OkOnly Or MsgBoxStyle.Exclamation, "System Date Changed")
			End If
			'disables app
			If blnEnabled = False Then
				If MsgBox("FRED is disabled", MsgBoxStyle.OkOnly Or MsgBoxStyle.Information, "Disabled") = MsgBoxResult.Ok Then
					For Each form As Form In My.Application.OpenForms
						form.Close()
					Next
				End If
			End If
		End If



So, first of all, check the number of days between the date the application was last ran, and today's date according to the system clock. If today's date is before the date the application was last ran, then the program will issue a warning, basically saying 'We know you changed your clock to an earlier date. Because this is the first time you've done this, we'll be nice and give you a warning. Don't do it again". Then it changes the intTime variable to 2 in case they try this trick a second time. This code can easily be changed to give more or fewer warnings before disabling the trial. All you will need to do is move the line 'blnEnabled = False' to another If statement, and remember to keep adding 1 to intTime for every warning you wish to give the user.

For this example, we only give the 1 warning, so if the user tries changing the system clock again, it will disable the application and givbe a message basically saying 'We warned you". Then it offers a second messagebox telling the user it has been disabled, then closes any open forms.

Finally, the last piece of code we need is that which disables the application at the end of the trial. This part can be modified to change the length of the trial to whatever you see fit. Just change the '14' (all 3 of them in this piece of code) to however many days you want the user to trial your application.

		If DateDiff(DateInterval.Day, dteStartDate, Now) > 14 Then
			blnEnabled = False
			If blnEnabled = False Then
				If MsgBox("FRED has reached the end of it's trial.", MsgBoxStyle.OkOnly Or MsgBoxStyle.Information, "Trial Ended") = MsgBoxResult.Ok Then
					'Close all open forms
					For Each form As Form In My.Application.OpenForms
						form.Close()
					Next
				End If
			End If
		End If
		dteLastStart = Now
		If blnFirstTime = True Then
			blnFirstTime = False
		End If
		'Saves variable settings
		My.Settings.Save()

		lngTimeLeft = 14 - (DateDiff(DateInterval.Day, dteStartDate, Now))

		MsgBox("This is a 14-day trial version." & vbCrLf & "You have " & CStr(lngTimeLeft) & " days left.", MsgBoxStyle.OkOnly, "FRED Trial")



The very end records the date the program is ran, saves the settings, and gives a messagebox telling the user how many days are left.

If you have any questions or comments about this, please post them here.

Happy coding,
Bort

Was This Post Helpful? 0
  • +
  • -

#14 mike.nelson  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 10-November 09

Posted 10 November 2009 - 07:10 AM

Bort,

I am new to programming and am trying to learn it myself. Not doing too bad so far. Just have a question, Where do I put the code? In the Form Load section.

Thanks for the code. I learn more and more everyday just by looking at sites like this.
Was This Post Helpful? 0
  • +
  • -

#15 Bort  Icon User is offline

  • Ill-informed Mongoloid
  • member icon

Reputation: 404
  • View blog
  • Posts: 2,983
  • Joined: 18-September 06

Posted 10 November 2009 - 07:13 AM

Yes. If you are just using the code as it is now, it needs to go in the Form_Load event.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2