-2

I am trying to find all possible permutations from the following conditions:

Number range 1-99

Letter range A-F

32 Digit long string

What would you recommend to make my life easier? Tried to search about permutations in vb, but just can't find them, and I don't know why but it doesn't seem such an hard task as that :s

Samples:

9A E5 4B CA BD 93 DE 2E 01 00 00 01 00 00 00 00

6E C7 9A CF CB A7 67 D9 17 EE 6B 70 F0 5E E4 32

64 86 00 EA 91 71 65 67 1F CE FE EB B1 CC 07 84

63 C0 8A AD F7 9F 5D F3 06 01 00 07 00 00 00 00

51 16 15 7C 56 9F 0A FF 55 1C 20 91 58 CD AA CF

48 61 56 FF 41 6E 49 F8 45 70 49 FE 54 75 52 1B

45 BA B8 B7 42 52 E3 77 03 00 00 03 00 00 00 00

40 D0 F4 04 BF AF 2B 99 02 00 00 02 00 00 00 00

40 30 90 00 3F 7C 83 3E 68 98 D5 D5 6D D9 A3 E9

FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF

FE A1 CE 6D A6 82 A9 D1 00 00 00 00 00 00 00 00

Thanks for helpin!

EDIT:

Here's my code

Public Class Form1
Dim c As Integer
Dim p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, a As String
Dim combo As String
Dim random As Random
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    c = -1
    While c <= 99
        c = c + 1
        If c < 10 Then
            a = "0" & c
        Else : a = c
        End If
        p1 = a
        p2 = 2
        combo = p1 + " " + p2 + " " + p3 + " " + p4 + " " + p5 + " " + p6 + " " + p7 + " " + p8 + " " + p9 + " " + p10 + " " + p11 + " " + p12 + " " + p13 + " " + p14 + " " + p15 + " " + p16 + " " + vbNewLine
        RichTextBox1.AppendText(combo + vbNewLine)
    End While
End Sub

End Class

  • This isn't a code-writing service. You need to put in some effort and show us what code you have tried so far. – Andrew Oct 17 '14 at 16:39
  • 3
    Questions asking us to **write code for your requirements** are off-topic for Stack Overflow as they are not about solving a specific problem with code, but rather are asking the community to do your work for you. Instead, make an attempt at writing code and if you encounter a problem, narrow the question to that specific problem and show what has been done so far to try solve it. – Ňɏssa Pøngjǣrdenlarp Oct 17 '14 at 16:41
  • You've not included anything to do with permutations. You've provided a hex dump of some data (probably parts of a file). What exactly are you asking, and what have you tried so far to figure it out yourself? – Ken White Oct 17 '14 at 16:41
  • You would ignore the "numbers and letters" since that is a hexadecimal notation of bytes (AF == 175) There are 16 bytes, each of which can hold 0 to 255 so you have **340,282,366,920,938,463,463,374,607,431,768,211,455** possible combinations. – Alex K. Oct 17 '14 at 16:53
  • I had posted a solution for getting all values between 00-FF then realized that you wanted 16 combinations of 00-FF... That is insanity as @AlexK. pointed out. – JNevill Oct 17 '14 at 17:17
  • Somethings really shouldnt be attempted in VBA. Do you have access to ANY other language tools – Toby Allen Oct 18 '14 at 09:34

1 Answers1

1

Judging from your example, you mean 0-9 (not 1-9) and A-F

Alex K. neatly provides a direction to solve this:

You would ignore the "numbers and letters" since that is a hexadecimal notation of bytes (AF == 175) There are 16 bytes, each of which can hold 0 to 255 so you have 340,282,366,920,938,463,463,374,607,431,768,211,455 possible combinations.

Although it is theoretically possible to get all of these permutations, your computer needs about 34,028,236,692,093,846,346,337,460,743 GB. I don't think that much memory exists in total

If it were a relatively tiny number, we could do this simply with the following method:

Sub purgatory()
    Dim counter As Long
    Dim output As String

    counter = 0
    For counter = 0 To 2147483647#
        output = String(16 - Len(Hex(counter)), "0") & Hex(counter)
        MsgBox output
    Next counter
End Sub

But the max value of a long in VBA7 is 2,147,483,648 (4 Bytes / 2), or 8 bytes with VB net. Which means that 12 bytes and one bit will always be 0. This could be solved with a few nested for loops.

I think the solution to your problem is best answered by JNevill

16 combinations of 00-FF... That is insanity...

IMPORTANT NOTE: If you run the code I posted, it's important to first familiarize yourself with Ctr+Pause/Break. Quickest way out of purgatory ;)

Alter
  • 3,332
  • 4
  • 31
  • 56