We help IT Professionals succeed at work.

# String Generation

on
183 Views
I want to generate strings as follow:
there 14 characters : '0','1','2','3','4','5','6','7','8','9','0','a','b','c','d'.
I want to generate all of the combinations. That is:
'01'
'02'
'03'
'04'
'05'
'06'
....
'0d'
.....
'0123456789abcd'

would somebody please tell me how to do so ? thanks .

Comment
Watch Question

## View Solution Only

Commented:
Those are thousands of combinations!

Commented:
that would be something like...

14^14 = 11,112,006,825,558,016 combinations...

The other thing is, if you want to figure this out for hex you are forgetting e & f. its abcdef.

-Brian

Commented:
wait unless you want it in hex? do you want hex values?

add a listbox to a form.

dim val as string
for i = 1 to 255
val = hex(i)
next i

Commented:
11,112,006,825,558,016 combinations, approximately
55,560,034,127,790,080 clock cycles (5 ticks per combinatory generation)
at 1.0 GHz, approximately:
15433.342813275022222222222222222 hours,
approximately:
643.05595055312592592592592592583 days
approximately:
21 months

to generate; even at 1 tick per combinatory generation:
approximately 128.61 days to generate.
Sounds like a hex crack to me; but, hey: what do I know, except that that generation would take between 4 and 21 months to create.

-- CM

Commented:
What do you mean by all possible combinations?  Will each combination be 2 chars in length?  If so, then...

dim sOuter() as string
dim sInner() as string
dim iOuter as integer
dim iInner as integer

sOuter= split("0,1,2,3,4,5,6,7,8,9,0,a,b,c,d", ",")
sInner = sOuter

for iOuter = lbound(sOuter) to ubound(sOuter)
for iInner = lbound(sInner) to ubound(sInner)
next iInner
next iOuter

Of course, that extra '0' you have after the nine will generate a duplicate of the first '0' in front of the '1'.  This is only 1369 combinations.  With out the extra '0' it is 1296 possible combinations.  Unless you actually want it it generate '0123456789abcd'.  That would take a long time, but the same concept would apply (sort of).

Commented:
Actually , the no of character will grow up to 30 characters. Is it impossible to do it ?

dim val as string
for i = 1 to 255
val = hex(i)
next i

Would you please tell me what will come out ? Thanks

Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
Unlock the solution to this question.

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.