|
-
Jan 23rd, 2006, 09:38 PM
#1
Thread Starter
Junior Member
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.
-
Jan 23rd, 2006, 09:47 PM
#2
Re: al possibl 3 lettered combination using a-z(only small characters),0-9,and -(hyph
VB Code:
Private Sub Command1_Click()
Dim myStr As String
Dim counter As Integer
Dim rndNum As Integer
counter = 0
Do While counter < 3
rndNum = Int(Rnd * 73) + 45
If rndNum = 45 Or (rndNum >= 48 And rndNum <= 57) Or (rndNum >= 97 And rndNum <= 122) Then
myStr = myStr & Chr(rndNum)
counter = counter + 1
End If
Loop
MsgBox myStr
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.
-
Jan 23rd, 2006, 10:12 PM
#3
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.
-
Jan 23rd, 2006, 10:17 PM
#4
Thread Starter
Junior Member
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..
-
Jan 23rd, 2006, 10:19 PM
#5
Re: al possibl 3 lettered combination using a-z(only small characters),0-9,and -(hyph
 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:
Private sPerms() As String
Private Sub FillArray()
Dim iOne As Integer, iTwo As Integer, iThree As Integer, sTemp As String, lIndex As Long
ReDim sPerms((37 ^ 3) - 1)
For iOne = 1 To 37
For iTwo = 1 To 37
For iThree = 1 To 37
Select Case iOne
Case 1 To 10
sTemp = Chr$(iOne + 47)
Case 11 To 36
sTemp = Chr$(iOne + 86)
Case Else
sTemp = "-"
End Select
Select Case iTwo
Case 1 To 10
sTemp = sTemp & Chr$(iTwo + 47)
Case 11 To 36
sTemp = sTemp & Chr$(iTwo + 86)
Case Else
sTemp = sTemp & "-"
End Select
Select Case iThree
Case 1 To 10
sTemp = sTemp & Chr$(iThree + 47)
Case 11 To 36
sTemp = sTemp & Chr$(iThree + 86)
Case Else
sTemp = sTemp & "-"
End Select
sPerms(lIndex) = sTemp
lIndex = lIndex + 1
Next iThree
Next iTwo
Next iOne
End Sub
-
Jan 23rd, 2006, 10:20 PM
#6
Re: al possibl 3 lettered combination using a-z(only small characters),0-9,and -(hyph
 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.
-
Jan 23rd, 2006, 10:54 PM
#7
Thread Starter
Junior Member
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.
-
Jan 23rd, 2006, 11:05 PM
#8
Re: al possibl 3 lettered combination using a-z(only small characters),0-9,and -(hyph
 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:
Dim sOut As String 'Nother variable.
'....
sOut = sOut & sTemp & vbCrLf 'Add
' sPerms(lIndex) = sTemp 'Remove
' lIndex = lIndex + 1
-
Jan 23rd, 2006, 11:07 PM
#9
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.
-
Jan 23rd, 2006, 11:30 PM
#10
Thread Starter
Junior Member
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..
-
Jan 24th, 2006, 02:34 AM
#11
Thread Starter
Junior Member
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.
-
Jan 24th, 2006, 02:44 AM
#12
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
-
Jan 24th, 2006, 02:56 AM
#13
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:
Dim strtline As Long
Dim fnshline As Long
Private Sub Command1_Click()
Dim strstring As String
Dim line() As String
lines = Split(Text1.Text, vbCrLf)
If fnshline = 0 Then fnshline = 4 '4 means 5 items
If fnshline < UBound(lines) Then
For x = strtline To fnshline
strstring = strstring & lines(x) & vbCrLf
Next
Else
For x = strtline To UBound(lines)
strstring = strstring & lines(x) & vbCrLf
Next
End If
Clipboard.Clear
Clipboard.SetText strstring
strtline = fnshline + 1
fnshline = fnshline + 5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|