PC Review


Reply
Thread Tools Rate Thread

Access Serial Number VB Programming

 
 
New Member
Join Date: Mar 2011
Posts: 1
 
      29th Mar 2011
Please someone Help me. I have a Key generator in ms access form which generate Serial keys; Ie the Key is [TLZEG-KXAMF-IHIXT-NEIRC-XEFCT]
But it doesn’t work on the following code
Public Function ValidateKey(strKey1 As String, strKey2 As String, strKey3 As String, _
strKey4 As String, strKey5 As String) As Boolean
'Variables
Dim i As Integer
Dim strKey As String
Dim strChr As String
Dim strNum As String
Dim strCode As String
Dim strTemp As String
Dim strTemp2 As String
Dim intTemp As Integer
'No Blanks
If Trim(strKey1) = "" Or Trim(strKey2) = "" Or Trim(strKey3) = "" Or _
Trim(strKey4) = "" Or Trim(strKey5) = "" Then
ValidateKey = False
Exit Function
End If
'All Must Be 5Chrs
If Len(strKey1) <> 5 Or Len(strKey2) <> 5 Or Len(strKey3) <> 5 Or _
Len(strKey4) <> 5 Or Len(strKey5) <> 5 Then
ValidateKey = False
Exit Function
End If
'Last Char of Key5 Must be the First Char of Key1
If Mid(strKey1, 1, 1) <> Right(strKey5, 1) Then
ValidateKey = False
Exit Function
End If
'Setup Key
strKey = strKey1 & strKey2 & strKey3 & strKey4 & strKey5
'Assemble String of 10 Characters
strChr = Mid(strKey, 1, 3) & Mid(strKey, 6, 2) & Mid(strKey, 9, 1) & _
Mid(strKey, 14, 3) & Mid(strKey, 19, 1)
'Assemble String of What will be 10 Numbers
strNum = Mid(strKey, 4, 2) & Mid(strKey, 8, 1) & Mid(strKey, 10, 4) & _
Mid(strKey, 17, 2) & Mid(strKey, 20, 1)
'Collect What will be the code
strCode = Right(strKey, 5)
'Make Sure 3 Characters in strCode Match with Appropriate Number and Alpha Keys
If Mid(strCode, 1, 1) <> Mid(strChr, 5, 1) Then
ValidateKey = False
Exit Function
End If
If Mid(strCode, 2, 1) <> Mid(strNum, 1, 1) Then
ValidateKey = False
Exit Function
End If
If Right(strCode, 1) <> Mid(strChr, 1, 1) Then
ValidateKey = False
Exit Function
End If
'Convert strNum Characters to ASC and Keep Last Digit
For i = 1 To Len(strNum)
strTemp = strTemp & Right(CStr((Asc(Mid(strNum, i, 1)) - 65)), 1)
Next
'Convert strChr Characters to ASC and Keep Last Digit
For i = 1 To Len(strChr)
strTemp2 = strTemp2 & Right(CStr((Asc(Mid(strChr, i, 1)))), 1)
Next
'The ASC in strTemp must match the asc in strTemp2
If strTemp <> strTemp2 Then
ValidateKey = False
Exit Function
End If
'Add Up SUm of Each Unique Number in ASC of Chr String
For i = 1 To Len(strNum)
intTemp = intTemp + CInt(Right(CStr((Asc(Mid(strNum, i, 1)) - 65)), 1))
Next
strTemp = CStr(intTemp)
'Resize the Code & Extract Num Val
strCode = Mid(strCode, 3, 2)
strCode = Right(CStr((Asc(Mid(strCode, 1, 1)) - 65)), 1) & _
Right(CStr((Asc(Mid(strCode, 2, 1)) - 65)), 1)
'Does the Extracted Num match the Group Sum?
If strTemp <> strCode Then
ValidateKey = False
Exit Function
End If
'Key Looks Good
ValidateKey = True
End Function
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Determine USB HDD Serial Number (NOT Volume Serial!) Connah Storage Devices 5 21st Jun 2007 04:42 PM
Determine USB HDD Serial Number (NOT Volume Serial!) Matthew Connor Microsoft VB .NET 6 20th Jun 2007 05:40 PM
hard disk serial number routine for Access? kingjepoy via AccessMonster.com Microsoft Access Security 0 3rd Mar 2006 06:13 AM
serial number in Access =?Utf-8?B?c3R1ZGVudG1wdGM=?= Microsoft Access 2 26th Feb 2005 07:19 AM
microsoft access serial number database trouble Buddy Microsoft Access Database Table Design 3 14th Jan 2004 05:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:32 PM.