Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Reading a txt-file with license-code

I'm thinking of making software add-in in VBA for MS Excel.
I will 'rent' this add-ins out and send my clients a new license-code every
month after the bills are paid.
This license-code is (at least now in the beginning) planned to be emailed
over in txt files (which the client has to store in their "My Documents").
Inside the file, with the name "license-code.txt" a license-code like
dk3-3kk-555-777 would be found.

So to have this license-code being 'useful' I need to program a function
which check whether the valid license-code is in place or not (toward
current month).
I plan to put in the function enough license-codes to cover the next 10
years, so the total of text-code which needs to be searched will be 10 x 12
months = 120 license-codes.

Now we are at the core of my question: Will this way of doing the licence
check result in a slow working code (I assume Select case will be used)?

(- anyone who have samples of such code?) Thanks, JohS


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Reading a txt-file with license-code

Several things come to mind. First, be aware that someone proficient
with VBA and sufficiently motivated can get around any sort of
licensing requirements. Next, I would include the expiration date
within the license key itself. You don't want to distribute all the
keys to the user and you don't want to have to read through and parse
out 120 keys every time the user opens the file. Unnecessary overhead.

Just take the serial date of the expiration date and scramble it amid
some meaningless characters. E.g.,

xDxxxxDxxxxxDDxDxxx

where x are some arbitrary characters and the D's are digits of the
serial date. For example, the string

13t5e49a245a9532s20

encodes the number 39952 which is the serial date of 19-May-2009.
While this isn't NSA-level coding, it will be sufficient for 99.9% of
the end users.

For simplicity, I would put the license text file in the same
directory as the XLA file, rather than in My Documents (whose name and
location varies by OS version and locale). Then you can use code like

Function IsValidKey() As Boolean
Dim FName As String
Dim FNum As Integer
Dim S As String
Dim T As String
Dim D As Date
On Error GoTo ErrH:
FName = ThisWorkbook.Path & "\Test.txt"
FNum = FreeFile
Open FName For Input Access Read As #FNum
Line Input #FNum, S
Close #FNum
T = Mid(S, 2, 1) & Mid(S, 7, 1) & Mid(S, 13, 2) & Mid(S, 16, 1)
D = CDate(CLng(T))
If D < Now Then
IsValidKey = False
Else
IsValidKey = True
End If
Exit Function
ErrH:
IsValidKey = False
End Function

With this code in place, you can call it from the Workbook_Open event
and if it returns False, kick the user out of the program.


Private Sub Workbook_Open()
Dim B As Boolean
B = IsValidKey()
If B = False Then
MsgBox "Your license has expired.", vbOKOnly
ThisWorkbook.Close savechanges:=False
End If
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)






On Sat, 18 Apr 2009 22:34:06 +0200, "JohS"
wrote:

I'm thinking of making software add-in in VBA for MS Excel.
I will 'rent' this add-ins out and send my clients a new license-code every
month after the bills are paid.
This license-code is (at least now in the beginning) planned to be emailed
over in txt files (which the client has to store in their "My Documents").
Inside the file, with the name "license-code.txt" a license-code like
dk3-3kk-555-777 would be found.

So to have this license-code being 'useful' I need to program a function
which check whether the valid license-code is in place or not (toward
current month).
I plan to put in the function enough license-codes to cover the next 10
years, so the total of text-code which needs to be searched will be 10 x 12
months = 120 license-codes.

Now we are at the core of my question: Will this way of doing the licence
check result in a slow working code (I assume Select case will be used)?

(- anyone who have samples of such code?) Thanks, JohS

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
reading txt file and copying the lines in new excel file [email protected] Excel Programming 2 August 11th 06 07:20 PM
reading from another file and pasting to current file, "combobox" Darius New Users to Excel 1 September 26th 05 07:13 AM
reading data from 2nd file in 1st file using Combobox Darius Excel Programming 0 September 22nd 05 04:51 PM
Reading complete Excel using DDE code amitkrsingh Excel Programming 1 August 19th 05 02:43 PM
reading from text file to excel file dgoel Excel Programming 0 April 18th 05 06:49 PM


All times are GMT +1. The time now is 06:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"