DateGood Function Help Required

mianmazher

Active Member
Joined
Jan 24, 2004
Messages
412
Option Explicit

Public Function DateGood(NumDays As Integer) As Boolean
'The purpose of this module is to allow you to place a time
'limit on the unregistered use of your shareware application.
'This module can not be defeated by rolling back the system clock.
'Simply call the DateGood function when your application is first
'loading, passing it the number of days it can be used without
'registering.
'
'Ex: If DateGood(30)=False Then
' CrippleApplication
' End if
'Register Parameters:
' CRD: Current Run Date
' LRD: Last Run Date
' FRD: First Run Date

Dim TmpCRD As Date
Dim TmpLRD As Date
Dim TmpFRD As Date

TmpCRD = Format(Now, "m/d/yy")
TmpLRD = GetSetting(App.EXEName, "Param", "LRD", "1/1/2000")
TmpFRD = GetSetting(App.EXEName, "Param", "FRD", "1/1/2000")
DateGood = False

'If this is the applications first load, write initial settings
'to the register
If TmpLRD = "1/1/2000" Then
SaveSetting App.EXEName, "Param", "LRD", TmpCRD
SaveSetting App.EXEName, "Param", "FRD", TmpCRD
End If
'Read LRD and FRD from register
TmpLRD = GetSetting(App.EXEName, "Param", "LRD", "1/1/2000")
TmpFRD = GetSetting(App.EXEName, "Param", "FRD", "1/1/2000")

If TmpFRD > TmpCRD Then 'System clock rolled back
DateGood = False
ElseIf Now > DateAdd("d", NumDays, TmpFRD) Then 'Expiration expired
DateGood = False
ElseIf TmpCRD > TmpLRD Then 'Everything OK write New LRD date
SaveSetting App.EXEName, "Param", "LRD", TmpCRD
DateGood = True
ElseIf TmpCRD = Format(TmpLRD, "m/d/yy") Then
DateGood = True
Else
DateGood = False
End If
End Function


Usage

Private Sub Form_Activate()
If Not DateGood(30) Then
MsgBox "Trial Period Expired!", vbExclamation, "Unregistered application"
Unload Me
End If
End Sub



I got this from the forum .


As a newbie in the VBA I dont now how to use this

Plz help me by telling where to place teh code

which lines to modify and how to use


Regards


Mian Mazher
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hi,

You'll forgive me wondering about the oddity of someone asking the following:

"As a newbie in the VBA I dont now how to use this...Plz help me by telling where to place teh code...which lines to modify and how to use"

...about code designed to protect an application - what have you got that's worth protecting?

At the very least, you'd need to give us an indication about what you are trying to do for any answers to "which lines to modify and how to use" to be meaningful.

that said, see:

http://www.danielklann.com/excel/where_do_i_place_code_in_excel.htm

...for some info on, unsurprisingly, where to place code in excel.
 
Upvote 0

Forum statistics

Threads
1,215,051
Messages
6,122,871
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top