title: Making a Trial version of a program
body: <p>I am making trial version of my <code>vb .net</code> project but it is not counting the days , date and time . </p>
  
  <p>Can u please give me any suggestions to correct it. I am using the following code</p>
  
  <pre><code>Public Class Form1
  
  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      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
  
  
      If DateDiff(DateInterval.Day, dteLastStart, Now) &lt; 0 Then
          'First clock change
          If intTime = 1 Then
              MsgBox("FRED has detected that you have changed your system date to an earlier date" &amp; vbCrLf &amp; "As FRED has built-in security," &amp; vbCrLf &amp; "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" &amp; vbCrLf &amp; "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
  
      If DateDiff(DateInterval.Day, dteStartDate, Now) &gt; 29 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 = 29 - (DateDiff(DateInterval.Day, dteStartDate, Now))
  
      MsgBox("This is a 29-day trial version." &amp; vbCrLf &amp; "You have " &amp; CStr(lngTimeLeft) &amp; " days left.", MsgBoxStyle.OkOnly, "FRED Trial")
  end sub
  end class
  </code></pre>