Solved

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

Posted on 2006-11-03
6
1,611 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
6 Comments
 
LVL 4

Accepted Solution

by:
hclgroup earned 168 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 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 166 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 84

Assisted Solution

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

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now