|
-
Oct 8th, 2012, 12:17 PM
#1
Thread Starter
PowerPoster
[RESOLVED] Trying to create a registration code with numbers and letters
Example:
Function DisectText(sText As String) As Boolean
Dim TextPart As String
Dim NumberPart As Long
'example 20K1W1E76N31606
End Function
need to verify that the user enters the correct text part of the string and
plan on checking the last 5 numbers between a given range;
eg;
if the last 5 digits (31606)
if the NumberPart is between 31606 and 32500
and the TextPart = KWEN
then DisectText =true
How would i write this code ?
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Oct 9th, 2012, 08:10 AM
#2
Re: [RESOLVED] Trying to create a registration code with numbers and letters
20K1W1E76N31606
Assuming the Reg is always 15 chars long
and the format is always
nnananannannnnn where n is numeric and a is alpha
the numberpart 31606 is retrieved with val(right$(stext,5))
the textpart is simply mid$(stext,3,1) & the other 3: 5,7,10
-
Oct 9th, 2012, 10:57 AM
#3
Re: [RESOLVED] Trying to create a registration code with numbers and letters
Oh that dreaded 'assume'.......:-) I am curious to see the code the OP used (never posted his Resolved code).....I wrote one where I TRIED to assume nothing.....char vs numeric, number of chars, etc, etc....turned out to be several lines of code....would love to see what the OP came up with, maybe I can shorten my code for future similar use. (Always trying to learn more.....).
-
Oct 9th, 2012, 12:18 PM
#4
Thread Starter
PowerPoster
Re: [RESOLVED] Trying to create a registration code with numbers and letters
i used this:
Public Function DisectText(ByVal texttodisect As String) As Boolean
Dim str1 As String
Dim str2 As String
Dim strval As Long
Dim part1 As Boolean
Dim part2 As Boolean
'20K1W1E76N31606 example
str1 = Mid(texttodisect, 3, 1) & Mid(texttodisect, 5, 1) & Mid(texttodisect, 7, 1) & Mid(texttodisect, 10, 1)
If str1 = "KWEN" Then part1 = True
str2 = Right(texttodisect, 5)
If (Val(str2) >= 31606 And Val(str2) <= 32500) Then part2 = True
If part1 = True And part2 = True Then
DisectText = True
Else
DisectText = False
End If
End Function
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Oct 9th, 2012, 01:31 PM
#5
Re: [RESOLVED] Trying to create a registration code with numbers and letters
YUP...shorter than mine...thanks ... forgot about if part1 and part2 = true.......duh!!!! Appreciate your response.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|