Results 1 to 5 of 5

Thread: [RESOLVED] Trying to create a registration code with numbers and letters

  1. #1

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Resolved [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

  2. #2
    Fanatic Member
    Join Date
    Mar 2009
    Posts
    804

    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

  3. #3
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    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.....).

  4. #4

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    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

  5. #5
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    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
  •  



Click Here to Expand Forum to Full Width