Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Genrate serial number like aa,ab,ac,ad......aaa,aab,aac...aaz,aba,abb,abc...abz

Posted on 2006-11-03
6
Medium Priority
?
1,901 Views
Last Modified: 2010-05-18
hello ,
i have two text box and in that u can enter a-z character and same in another textbox , now i want to genrate all the possiblity of that character...

like if i have put in first textbox aa and in second zz  it woulb be gerate 676 combination of that two no..like aa,ab,ac,ad...az,ba....bz,ca.....czlike that
and if i put aaa and ffff it wil be genrate   cobmination  ilke this type of coding

it will possible???????????????
0
Comment
Question by:pradeepppatel
3 Comments
 
LVL 4

Accepted Solution

by:
hclgroup earned 672 total points
ID: 17868705
All you need is a function to increment strings

VB example
http://www.freevbcode.com/ShowCode.asp?ID=5440

All you then need to do is continuously increment the first string until it is equal to the second string.
(you would also need to verify that the second string is greater than or equal to the first string)
0
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 664 total points
ID: 17868985
Here is another implementation that allows you to easily customize the characters used in the "sequence":

Option Explicit

Private Sub Command1_Click()
    Text1.Text = NextRevision(Text1.Text)
End Sub

Private Function NextRevision(Optional ByVal curRevision As String) As String
    Dim i As Integer
    Dim char As String
    Dim chars As String
    Dim index As Integer
    Dim charArray() As String
   
    ' modify the line below to include the characters you
    ' want in the sequence
    chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"
   
    ' blank revision passed in, return first letter in sequence
    curRevision = Trim(UCase(curRevision))
    If curRevision = "" Then
        NextRevision = Left(chars, 1)
        Exit Function
    End If
   
    ' make sure current revision has only valid characters in it
    ' otherwise...return first letter in sequence
    For i = 1 To Len(curRevision)
        char = Mid(curRevision, i, 1)
        If InStr(chars, char) = 0 Then
            MsgBox "Returning: " & Left(chars, 1), vbCritical, "Invalid Starting Revision: " & curRevision
            NextRevision = Left(chars, 1)
            Exit Function
        End If
    Next i
   
    ' build a character array from the current revision
    ReDim charArray(Len(curRevision) - 1)
    For i = 1 To Len(curRevision)
        charArray(i - 1) = Mid(curRevision, i, 1)
    Next i
   
    ' see if the just the last letter needs to be "incremented"
    char = charArray(UBound(charArray))
    index = InStr(chars, char)
    If index < Len(chars) Then
        charArray(UBound(charArray)) = Mid(chars, index + 1, 1)
        NextRevision = Join(charArray, "")
        Exit Function
    End If
               
    ' last letter "rolled over"
    ' propagate the "carry over" as far as it needs to go
    charArray(UBound(charArray)) = Left(chars, 1)
    For i = UBound(charArray) - 1 To 0 Step -1
        char = charArray(i)
        index = InStr(chars, char)
        If index < Len(chars) Then
            index = index + 1
            charArray(i) = Mid(chars, index, 1)
            NextRevision = Join(charArray, "")
            Exit Function
        Else
            charArray(i) = Left(chars, 1)
        End If
    Next i
   
    ' "carry over" propagated all the way thru sequence
    ' add first letter of sequence to the beginning of the revision
    NextRevision = Left(chars, 1) & Join(charArray, "")
End Function
0
 
LVL 85

Assisted Solution

by:ozo
ozo earned 664 total points
ID: 17869745
#!/usr/bin/perl
$\=",";
print for 'aa' .. 'cz';
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Progress
Screencast - Getting to Know the Pipeline

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question