We help IT Professionals succeed at work.

String Generation

mikekwok asked
Last Modified: 2010-05-03
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:

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

Watch Question

Those are thousands of combinations!
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.

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)
list1.additem val
next i
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,
643.05595055312592592592592592583 days
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
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)
           List1.AddItem sOuter(iOuter) & sInner(iInner)
      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).


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

Brian,  For your code,

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

Would you please tell me what will come out ? Thanks

This one is on us!
(Get your first solution completely free - no credit card required)
Unlock the solution to this question.
Join our community and discover your potential

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.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.