How to locate 4 digits into arrays

akn_my_183a's Avatar
Light Poster
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.
0
jwshepherd's Avatar, Join Date: Aug 2007
Team Leader
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)
0
akn_my_183a's Avatar
Light Poster
thanks for ur reply...
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.
0
jwshepherd's Avatar, Join Date: Aug 2007
Team Leader
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
0
akn_my_183a's Avatar
Light Poster
but this method will have repeated number, how to get unique number??