Lightbulb[VB6] Permutation Counter

Posts 1–8 of 8 · Page 1 of 1
[VB6] Permutation Counter
Credits: falzarex
Creator: stonie & falzarex

What is permutation?
The number of possible combinations of a given set of numbers in which each permutation is unique.

What does this code do?
Tells you the permutation of any givin length up to 170.
Basically allows you to input a value and the number of permutations calculated will be returned.
Up to 17 is redable data. Anything over returns E+. Max VB allows is 170.

Permutation Function
Code:
Private Function Permutation(Value As Long) As String
On Error Resume Next
Dim n As Long, S As Long
n = 1
For S = 1 To Value
n = n * (S + 1 \ 2)
Next S
Permutation = CStr(n)
Err.Clear
End Function

Example of usage
Code:
Label1 = Permutation(Val(Text1.Text))
Lol coming up with the formula was tough :P
Quote Originally Posted by falzarex View Post
Lol coming up with the formula was tough :P
Yes it was! =)

This is how we narrowed it down:
Code:
'1 = c * (c + 1) = n
'2 = n * (c + 1) = n
'3 = n * (c + 1) = n
'1 = 1 * 2 = 2
'2 = 2 * 3 = 6
'3 = 6 * 4 = 24
'4 = 24 * 5 = 120
'5 = 120 * 6 = 720
'6 = 720 * 7 = 5040

720 / 120 = 6
It can be used to figure out how many times needed to loop in order to retrive every possable combination in a giving string.

falzarex originaly wanted something like this for jiberize, a fun text randomizer but still readable. I think it was UTAH university that came up with this stunning discovery that all words are readable if the first and last letter are not changed but in the middle still included all the letters to spell the word in any order.
I didn't really work on it much tho. Its not uniform and could be programmed better and neater.
The E+ is just showing that its to a power. Its still readable.
how would i use this in vb?
Quote Originally Posted by challengy View Post
how would i use this in vb?
Note: It is for VB6 (Microsoft Visual Studio 6)

Quote Originally Posted by stonie View Post
Example of usage
Code:
Label1 = Permutation(Val(Text1.Text))
Put the function anywhere in your project and use the above.
Code:
String = Permutation(Length of string to scan as a value)
'Permuation = Function name
--------------
Quote Originally Posted by wtfiwantthatname View Post
The E+ is just showing that its to a power. Its still readable.
Ya, I can only do 170. After 170 it errors and only displays the 170 count.
Quote Originally Posted by stonie View Post
Note: It is for VB6 (Microsoft Visual Studio 6)



Put the function anywhere in your project and use the above.
Code:
String = Permutation(Length of string to scan as a value)
'Permuation = Function name
--------------

Ya, I can only do 170. After 170 it errors and only displays the 170 count.
so i would put a label in the form? because it says label1
@challengy

Label1 = default name of the the first label placed on a form, so the answer is yes.

(could be 3rd place if 2 and 3 are already taken, but usually)
Posts 1–8 of 8 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

Talk with us