How to locate 4 digits into arrays

Discussion in 'Visual Basic ( VB )' started by akn_my_183a, Sep 13, 2007.

  1. akn_my_183a

    akn_my_183a New Member

    Joined:
    Aug 20, 2007
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    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. :)
     
  2. jwshepherd

    jwshepherd New Member

    Joined:
    Aug 13, 2007
    Messages:
    135
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    VP Technology Corporation
    Location:
    Texas
    Home Page:
    http://www.officialhackers.com
    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)
     
  3. akn_my_183a

    akn_my_183a New Member

    Joined:
    Aug 20, 2007
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  4. jwshepherd

    jwshepherd New Member

    Joined:
    Aug 13, 2007
    Messages:
    135
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    VP Technology Corporation
    Location:
    Texas
    Home Page:
    http://www.officialhackers.com
    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
    
     
  5. akn_my_183a

    akn_my_183a New Member

    Joined:
    Aug 20, 2007
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    but this method will have repeated number, how to get unique number??
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice