1,105,332 Community Members

Startup vb.net

Member Avatar
BE_Aus
Newbie Poster
1 post since Nov 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I do apologise for the simplicity of this post, but I am seeking help in something I have not encountered before.

While I have my splash screen and program humming perfectly, I am trying to run a date check while starting and exit the program if it is too old. In simple terms:

  1. Run the splash screen
  2. Check todays date
  3. If todays date is later than a given date, exit the program prior to my Form1 becoming visible.

Can anyone help with this please?

Member Avatar
Reverend Jim
Noli mentula
5,395 posts since Aug 2010
Reputation Points: 746 [?]
Q&As Helped to Solve: 643 [?]
Skill Endorsements: 51 [?]
Moderator
Featured
 
0
 
If DateDiff(DateInterval.Day, CDate("2013-10-01"), Now) > 10 Then
    MsgBox("program too old")
    Me.Close()
End If

If you want to save a date, for example, the date the program was first run, you could create an application level settings variable and give it a known initial value like 2013-01-01 then do

If My.Settings.FirstRun = Cdate("2000-01-01") Then
    My.Settings.FirstRun = Now
End If

If DateDiff(DateInterval.Day, My.Settings.FirstRun, Now) > 10 Then
    MsgBox("program too old")
    Me.Close()
End If
Member Avatar
DM Galaxy
Junior Poster in Training
65 posts since Aug 2013
Reputation Points: -6 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 5 [?]
 
0
 

this is similar to trial version product:
you can do this with the settings (create settings)
This feature will store data in the application itself
Secondly, You can also use the registry for this

as reverend jim told you that you can do or you can do this too:
(your application name: MyPro; trial version for: 30 days) change the day to 1 (according to your help needed)
Create a Function: (type below Public Class Form1)

Private Function HandleRegistry() As Boolean
        Dim firstRunDate As Date
        firstRunDate = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg", "FirstRun", Nothing)
        If firstRunDate = Nothing Then
            firstRunDate = Now
            My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\MyProg", "FirstRun", firstRunDate)
        ElseIf (Now - firstRunDate).Days > 30 Then
            Return False
        End If
        Return True
End Function

now called this handled report to your application
type code in the form1_loadevent

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Dim result As Boolean = HandleRegistry()
        If result = False Then 'something went wrong
            MsgBox("Trial expired")
            Application.exit()
        Else
            MsgBox("Trial version")
        End If
End Sub

what we did:?
We just create a registry entry value and that registry entry value will be stored on your FirstRun. and the data will be save
so that whenever you opened the application, then your application will count days left. if you have passed all trial days then your application will just opened and tell popup with msgbox (trial expired) and then application will end...

THANK YOU
still having doubt inform me

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article