Results 1 to 13 of 13

Thread: al possibl 3 lettered combination using a-z(only small characters),0-9,and -(hyphene)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    26

    al possibl 3 lettered combination using a-z(only small characters),0-9,and -(hyphene)

    I just need a help for me to just generate all the possible combinations as a 3 lettered using a-z(only small characters),0-9,and -(hyphene) only.

    the possible combinations can be aa9,a-9,s9h,7-g,etc..

    Can any one help me with the possible code.

    This combinations has to be generated once the application is loaded.

  2. #2
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: al possibl 3 lettered combination using a-z(only small characters),0-9,and -(hyph

    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3.     Dim myStr As String
    4.     Dim counter As Integer
    5.     Dim rndNum As Integer
    6.    
    7.     counter = 0
    8.     Do While counter < 3
    9.         rndNum = Int(Rnd * 73) + 45
    10.         If rndNum = 45 Or (rndNum >= 48 And rndNum <= 57) Or (rndNum >= 97 And rndNum <= 122) Then
    11.             myStr = myStr & Chr(rndNum)
    12.             counter = counter + 1
    13.         End If
    14.     Loop
    15.    
    16.     MsgBox myStr
    17.  
    18. End Sub

    I have it in a command button for testing purposes... if you need it to work automatically when the form is started, just put it in the Form_Load event with myStr being a global variable.
    Last edited by timeshifter; Jan 23rd, 2006 at 09:54 PM.

  3. #3
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: al possibl 3 lettered combination using a-z(only small characters),0-9,and -(hyph

    You would have to loop thru the desired value 3 times in a nested loop, and eliminate values that you don't want. If you have a-a, does that mean that -aa and -a- are not allowed? That makes it more complicated.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    26

    Re: al possibl 3 lettered combination using a-z(only small characters),0-9,and -(hyphene)

    I just want these 3 letterd combinations all to be listed when the form is loaded ..if suppose i generate a-a,i need to generate -aa and also -a-, this can be listed in a richtext box when the form is loaded..if so how to add it in the rich text box..all the possible combinations allowed with these ..i think totally it will come around some 48000 to 49000 combinations..

  5. #5
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: al possibl 3 lettered combination using a-z(only small characters),0-9,and -(hyph

    Quote Originally Posted by timeshifter
    [SNIP]
    I have it in a command button for testing purposes... if you need it to work automatically when the form is started, just put it in the Form_Load event with myStr being a global variable.
    I think he was looking for all possible combinations, not just one random combination. Try this code:
    VB Code:
    1. Private sPerms() As String
    2.  
    3. Private Sub FillArray()
    4.  
    5.     Dim iOne As Integer, iTwo As Integer, iThree As Integer, sTemp As String, lIndex As Long
    6.    
    7.     ReDim sPerms((37 ^ 3) - 1)
    8.    
    9.     For iOne = 1 To 37
    10.         For iTwo = 1 To 37
    11.             For iThree = 1 To 37
    12.                 Select Case iOne
    13.                     Case 1 To 10
    14.                         sTemp = Chr$(iOne + 47)
    15.                     Case 11 To 36
    16.                         sTemp = Chr$(iOne + 86)
    17.                     Case Else
    18.                         sTemp = "-"
    19.                 End Select
    20.                 Select Case iTwo
    21.                     Case 1 To 10
    22.                         sTemp = sTemp & Chr$(iTwo + 47)
    23.                     Case 11 To 36
    24.                         sTemp = sTemp & Chr$(iTwo + 86)
    25.                     Case Else
    26.                         sTemp = sTemp & "-"
    27.                 End Select
    28.                 Select Case iThree
    29.                     Case 1 To 10
    30.                         sTemp = sTemp & Chr$(iThree + 47)
    31.                     Case 11 To 36
    32.                         sTemp = sTemp & Chr$(iThree + 86)
    33.                     Case Else
    34.                         sTemp = sTemp & "-"
    35.                 End Select
    36.                 sPerms(lIndex) = sTemp
    37.                 lIndex = lIndex + 1
    38.             Next iThree
    39.         Next iTwo
    40.     Next iOne
    41.    
    42. End Sub

  6. #6
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: al possibl 3 lettered combination using a-z(only small characters),0-9,and -(hyph

    Quote Originally Posted by Joe_anna
    I just want these 3 letterd combinations all to be listed when the form is loaded ..if suppose i generate a-a,i need to generate -aa and also -a-, this can be listed in a richtext box when the form is loaded..if so how to add it in the rich text box..all the possible combinations allowed with these ..i think totally it will come around some 48000 to 49000 combinations..
    Actually, it's 50653 combinations.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    26

    Re: al possibl 3 lettered combination using a-z(only small characters),0-9,and -(hyphene)

    I have a rich text box in my design view..and these all possible combinations(50653 ) has to be listed in the rich text box when the form is loaded..How to proceed.

  8. #8
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: al possibl 3 lettered combination using a-z(only small characters),0-9,and -(hyph

    Quote Originally Posted by Joe_anna
    I have a rich text box in my design view..and these all possible combinations(50653 ) has to be listed in the rich text box when the form is loaded..How to proceed.
    Instead of writing them to an array, just make them into one long string and then assign it to the .Text property of the RTB. I.e:
    VB Code:
    1. Dim sOut As String                      'Nother variable.
    2.                 '....
    3.                 sOut = sOut & sTemp & vbCrLf            'Add
    4. '                sPerms(lIndex) = sTemp                 'Remove
    5. '                lIndex = lIndex + 1

  9. #9
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: al possibl 3 lettered combination using a-z(only small characters),0-9,and -(hyph

    Do you want them each on a separate line? Who wants to scroll thru 1000 pages? If you used a flexgrid, you could put 10 or more on each line, but you could also separate them in the rtb with commas or spaces.

    What are you using this for? There might be a better and easier way to display just what you need.

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    26

    Re: al possibl 3 lettered combination using a-z(only small characters),0-9,and -(hyphene)

    I need this in a separate line...once this is displayed in the richtectbox or flexgrid, i do have a button(Called SAVE) also near to the richtectbox or flexgrid , so once i click that button the first 100 nos should get selected automatically and then save it in a clipboard(Say a text file) then on the second click next 100 (101 - 200) should get selected..and that should be saved..Can u help to solve this probs..its very URGENT..

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    26

    Re: al possibl 3 lettered combination using a-z(only small characters),0-9,and -(hyphene)

    How do i select the text in the rich text box one by one..

    the text appears like..
    1
    2
    3
    4
    5
    First i need to select 1-3,then from 4-5...and soo on..

    Plz help.

  12. #12
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: al possibl 3 lettered combination using a-z(only small characters),0-9,and -(hyphene)

    use richtext.selstart and .sellength and seltext for this

  13. #13
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: al possibl 3 lettered combination using a-z(only small characters),0-9,and -(hyphene)

    You can use the split function and split the textbox into lines then loop through the lines you want like so
    VB Code:
    1. Dim strtline As Long
    2. Dim fnshline As Long
    3. Private Sub Command1_Click()
    4. Dim strstring As String
    5. Dim line() As String
    6.  
    7.  
    8. lines = Split(Text1.Text, vbCrLf)
    9.  
    10. If fnshline = 0 Then fnshline = 4   '4 means 5 items
    11.  
    12. If fnshline < UBound(lines) Then
    13.     For x = strtline To fnshline
    14.         strstring = strstring & lines(x) & vbCrLf
    15.     Next
    16. Else
    17.     For x = strtline To UBound(lines)
    18.         strstring = strstring & lines(x) & vbCrLf
    19.     Next
    20. End If
    21.  
    22. Clipboard.Clear
    23. Clipboard.SetText strstring
    24.  
    25.  
    26. strtline = fnshline + 1
    27. fnshline = fnshline + 5
    28.  
    29. End Sub

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