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:
  1. Function Factorial(intNumber As Long) As Long
  2.    If intNumber = 1 Then
  3.       Factorial = 1
  4.    Else
  5.       Factorial = intNumber * Factorial(intNumber - 1)
  6.    End If
  7. End Function


any ideas/help/ codes highly appreciated...,

ashky.