Interesting Program Problem

Hi how are you doing?
I was doing some practising on VB and came up on a problem. Now if I have 20 numbers numbered 1 to 20. And I would like to make security codes for some personnel. (hypothetically) The codes consist of 4 numbers. How would I write the program to find all the combinations of those 20 numbers. For example one of the combinations obviously will be 1234 how can I write a program to find ALL the combinations of those 20 numbers in groups of four? I would really appreciate it if you could help me out on this.

Comments

  • I don't do VB, but it can be done with a recursive FOR loop...I think they are for...next loops in BASIC...Basically (this probably won't compile)...you would need to do something like this:

    for number1 = 0, number1 <= 20, number1 = number1 + 1
    for number2 = 0, number2 <= 20, number2 = number2 + 1
    for number3 = 0, number3 <= 20, number3 = number3 + 1
    for number4 = 0, number4 <= 20, number4 = number4 + 1
    ....what you want to post or try with here....
    next number4
    next number3
    next number2
    next number1
    as such you are trying all possible numbers that can happen from 0-0-0-0 up to 20-20-20-20.

    Hope this helps you some....read up on how to do a for next loop in VB...it will help...

    Travis Ferguson

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion