Solved

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

Posted on 2006-11-03
6
1,632 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to open Waze.com/livemap from address saved in DB? 26 177
countHi challenge 25 100
wordappend challenge 8 149
Java Loop 6 49
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
A short article about a problem I had getting the GPS LocationListener working.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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 …

920 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

15 Experts available now in Live!

Get 1:1 Help Now