borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (NEED AGENTS IN GRAPHIC INDUSTRY)Next Topic (Please help me, i'm a novice) New Topic New Poll Post Reply
AndreaVB Forum : VB General : All possible combination of number
Poster Message
tri_inn
Level: Regular User
Registered: 26-08-2002
Posts: 395

icon All possible combination of number

say suppose may programm will have a one text box and one list box and i will give three digit like 159 in the text box and press enter key my programm will print all possible combination of 159 in the list view.i know it is easy programm but i dont have logic to complete this programm.if possible please solve my programm and help me with source code.

01-06-2003 at 02:38 PM
View Profile Send Email to User Show All Posts | Quote Reply
~Bean~
Level: VB Guru


Registered: 07-04-2003
Posts: 488
icon Re: All possible combination of number

I believe you're looking for code to determine the permutations of a string...

i.e.,
Permutations of string of length n = n!
in this case..."159"...
159 => 3! = 1*2*3 = 6 Which implies there are 6 permutations of the string "159" (or any 3 character string for that matter) =>{159},{195},{951},{915},{591},{519}
(for longer lengths of strings, programs typically use disk access to avoid memory overflow [i.e., n > 10]...and keep in mind the limit of number of items that a list box can hold, 32K I think)

There are almost as many ways (algorithms) to arrive at all the possible sets as there are permutations of 25!...lol...ahem...needless to say the technique you use may depend on the length of your string, whether this length varies, and whether speed is a real factor (*see FYI below). Code snippets can be lengthy for this type of operation - I have several which I found lying around which I can e-mail to you if you like, otherwise search your favorite code website for "permutation" and see what you find...




~Beans~ FY Du Jour - n! Beyond our Capabilities

Regarding permutations...

2! = 2
5! = 120
10! = 3,628,800
15! = 1,307,674,368,000
phew...
20! = 2,432,902,008,176,640,000 WOW!

Could you actually list the sets of 20! ?

Given current level of tech (CPU speed)...say, 1 billion permutations per second that 20! would take
2,432,902,008 seconds, or
40,548,367 minutes, or
675,806 hours, or
28,159 days, or
77 years!


WOWZERS!
  

[Edited by ~Bean~ on 02-06-2003 at 06:25 PM GMT]

____________________________
Eggheads unite! You have nothing to lose but your yolks.

01-06-2003 at 06:55 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: All possible combination of number

If what Bean said is what you want to do:

If the temp variable is long, it overflows at 13; if it's double it overflows (infinity) at 171



____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)

04-06-2003 at 12:25 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaVB Forum : VB General : All possible combination of number
Previous Topic (NEED AGENTS IN GRAPHIC INDUSTRY)Next Topic (Please help me, i'm a novice) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder