Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   How to locate 4 digits into arrays (http://www.go4expert.com/forums/locate-4-digits-arrays-t6357/)

 akn_my_183a 14Sep2007 00:22

How to locate 4 digits into arrays

Good days, everyone
For instance, i have one number with 4 digits (2234). There are 12 times to turn this 4digits:-

2234, 2243, 2324, 2342, 2432, 2423, 3224, 3242, 3422, 4322, 4232, 4223

So these digits remain the same, but the position of digits is different. Can anyone provide solution?

Thank you very much for ur kindness and assistance. :)

 jwshepherd 14Sep2007 02:25

Re: How to locate 4 digits into arrays

Your question is a little unclear. Not sure what you are wanting to accomplish completely.

i would probably suggest putting the 12 versions of the number into an array and call it with rnd

Code:

``` MyArray(1)=2234 Myarray(2)=2243 ... ... randomize x=int(rnd(12*1)+1) debug.print MyArray(x)```
something like that would return your numbers randomly (kinda)

 akn_my_183a 14Sep2007 06:56

Re: How to locate 4 digits into arrays

What i meant is i was given a number (2234). So i wish to generate a program to produce 12 numbers with same digits but different position.
Original number = 2234
Different position for this number :-
-2234
-2243
-2324
-2342
-2432
-2423
-3224
-3242
-3422
-4322
-4232
-4223
If i insert each number into array, it looks like inconsistency.

 jwshepherd 14Sep2007 09:50

Re: How to locate 4 digits into arrays

ok, here is quick and dirty. not pretty and not dynamic but it will get the results which should be actually 16 not 12.

Code:

```Dim x As Integer, y As Integer Dim a As Integer, b As Integer Dim c As Integer, d As Integer Dim intTemp As Integer Dim intlen As Integer intTemp = Text2.Text intlen = Len(intTemp) a = Mid\$(intTemp, 1, 1) b = Mid\$(intTemp, 2, 1) c = Mid\$(intTemp, 3, 1) d = Mid\$(intTemp, 4, 1) Text1.Text = Text1.Text & (a & b & c & d) & vbCrLf Text1.Text = Text1.Text & (a & c & b & d) & vbCrLf Text1.Text = Text1.Text & (a & d & c & b) & vbCrLf Text1.Text = Text1.Text & (a & d & b & c) & vbCrLf Text1.Text = Text1.Text & (b & a & c & d) & vbCrLf Text1.Text = Text1.Text & (b & c & a & d) & vbCrLf Text1.Text = Text1.Text & (b & d & c & a) & vbCrLf Text1.Text = Text1.Text & (b & d & a & c) & vbCrLf Text1.Text = Text1.Text & (c & b & a & d) & vbCrLf Text1.Text = Text1.Text & (c & b & d & a) & vbCrLf Text1.Text = Text1.Text & (c & d & a & b) & vbCrLf Text1.Text = Text1.Text & (c & d & c & a) & vbCrLf Text1.Text = Text1.Text & (d & b & c & a) & vbCrLf Text1.Text = Text1.Text & (d & c & b & a) & vbCrLf Text1.Text = Text1.Text & (d & a & c & b) & vbCrLf Text1.Text = Text1.Text & (d & a & b & c) & vbCrLf```

 akn_my_183a 14Sep2007 12:33

but this method will have repeated number, how to get unique number??

 All times are GMT +5.5. The time now is 06:33.