/ Published in: VB.NET
Created by Brandon
Expand |
Embed | Plain Text
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
Comments
Subscribe to comments
You need to login to post a comment.

This code could be reduced to a couple lines of code using the TimeSpan class.. This code is written way too complicated for handling this simple task.