Return to Snippet

Revision: 29432
at July 29, 2010 12:09 by brandonio21


Updated Code
Public Class Form1
    Public day As String 'Creates all the variables
    Public month As String
    Public year As String

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        day = My.Computer.Clock.LocalTime.Day 'Declares day,month,and year as the current Day Month and Year
        month = My.Computer.Clock.LocalTime.Month
        year = My.Computer.Clock.LocalTime.Year
        If My.Settings.checked = False Then 'Checks if this is the first time the program has run, if it is, save the current date into a setting.
            My.Settings.day = day
            My.Settings.month = month
            My.Settings.year = year
            My.Settings.checked = True
        Else
            Try 
                If year = My.Settings.year Then 'If the year is the same, check the month
                    If month = My.Settings.month Then

                    Else
'If the month is not the same then check if the day is
                        If month = My.Settings.month + 1 Then
                            If day = My.Settings.day Then
		msgbox("trial expired!")
                            Else 'If the day is bigger than the current day, the trial is expired
                                If day > My.Settings.day Then
                                    MsgBox("Trial expired!")
                                End If
                            End If
                        Else
                            If month = My.Settings.month + 2 Then
		msgbox("Trial Expired!")
	       Else
                                If month <> My.Settings.month + 1 Then
                                    MsgBox("Trial Expired!")
                                End If
                            End If
                        End If
                    End If
                Else
'If the year is different, the trial has expired
                    MsgBox("Trial Expired!")
                End If
'If there is an error, make a msgbox containing the error
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End If

    End Sub
End Class

Revision: 29431
at July 29, 2010 12:07 by brandonio21


Initial Code
Public Class Form1
    Public day As String ;Creates all the variables
    Public month As String
    Public year As String

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        day = My.Computer.Clock.LocalTime.Day ;Declares day,month,and year as the current Day Month and Year
        month = My.Computer.Clock.LocalTime.Month
        year = My.Computer.Clock.LocalTime.Year
        If My.Settings.checked = False Then ;Checks if this is the first time the program has run, if it is, save the current date into a setting.
            My.Settings.day = day
            My.Settings.month = month
            My.Settings.year = year
            My.Settings.checked = True
        Else
            Try 
                If year = My.Settings.year Then ;If the year is the same, check the month
                    If month = My.Settings.month Then

                    Else
;If the month is not the same then check if the day is
                        If month = My.Settings.month + 1 Then
                            If day = My.Settings.day Then
		msgbox("trial expired!")
                            Else ;If the day is bigger than the current day, the trial is expired
                                If day > My.Settings.day Then
                                    MsgBox("Trial expired!")
                                End If
                            End If
                        Else
                            If month = My.Settings.month + 2 Then
		msgbox("Trial Expired!")
	       Else
                                If month <> My.Settings.month + 1 Then
                                    MsgBox("Trial Expired!")
                                End If
                            End If
                        End If
                    End If
                Else
;If the year is different, the trial has expired
                    MsgBox("Trial Expired!")
                End If
;If there is an error, make a msgbox containing the error
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End If

    End Sub
End Class

Initial URL
http://brandonsoft.com

Initial Description
Created by Brandon

Initial Title
Vb.net Check for 30 day trial

Initial Tags

                                

Initial Language
VB.NET