|
-
Mar 26th, 2002, 03:44 PM
#1
String Query
Hai,
I am having 1 text box, 1 command button and a list box. number in the range 2 to 9 must be entered in the text box. On the click of the button the various cobinations of arrangements shld be added to the list box.
For example if the the number entered was 3:
Then we have,
123
132
213
231
312
321
The total number is clearly 3! ( 3 factorial
Similarly, if the input was 4, the total number of possible combinations is 4! (24) and they are:
1234
1243
1324
1342
1423
1432
2134
2143
2314
2341
2413
2431
3124
3142
3214
3241
3412
3421
4123
4132
4213
4231
4312
4321
I have the following way to find the max. number of possible combinations and we clearly know the string length, now how do i shuffle the digits to get the desired result.
VB Code:
Function Factorial(intNumber As Long) As Long
If intNumber = 1 Then
Factorial = 1
Else
Factorial = intNumber * Factorial(intNumber - 1)
End If
End Function
any ideas/help/ codes highly appreciated...,
ashky.
-
Mar 26th, 2002, 04:58 PM
#2
Those are permutations.
There is some code in this thread to look at:
http://www.vbforums.com/showthread.p...t=permutations
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
|