Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Get The Permutation Of Of 4-Digit Number

Thanks for reading below scenario:

It's about generate / get the permutation of 4 digit number .Example:
user will input 4-digit number at a text box, assume use input---> 1116
and there's command button, when you click on it, it will find the permutatiion of 1116 and display it at a label--> 1116 1161 1611 6111

Thank's for any help

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
4 Digit Permutation Out Of 5 Or More Numbers
I had seen lots of permutation example that generate out of 4 different numbers and it works perfectly well. But I need to generate a 4 digit permutation out of 5 or more different numbers.

Example: I got 5 number: 4,3,2,7,8 and I want some thing like this. 2347,8743,3247,8437,2378!


I got 6 number: 4,3,2,7,8,1 and I want some thing like this. 2317,8743,3217,8437,2378,1287,7128!

No matter how many numbers I have, I Only want 4 digit permutation.
Any ideas?

Hashing A 10 Digit Number To 8 Digit Alphanumeric
Can anyone help me with an algorithm to convert a 10 digit number to an 8 digit alphanumeric?

Preferably, I'd like the following constraints:

1. The number generated is unique - no two numbers will generate the same output
2. The algorithm is one way (irreversable) - not required but would be nice

Eg. Hash(7594865729) returns 8A74BZ65.

Any ideas?

Hashing A 10 Digit Number To A 2 Digit Alphanumeric
I need a function that does the following:

1. Takes a 10 digit number as input and creates a unique hash of that number
2. The hash should allow letters so that it can be shorter than the original number
3. The algorithm should be one-way (ie. irreversable)
4. I'm guessing by adding 26 letters (A to Z) with (0 to 9) will give 36 possibilities for each character. This means a 10 digit number can be hashed to a 2 digit alpha-numeric (?)

10^10 = 10000000000
2^36 = 68719476736

Eg. Hash(0374863796) returns A3 and no other 10 digit number (or < 10 digits) should produce A3.

Does anyone have any ideas about the algorithm to do such a thing. I've looked over the Net at hashing algs such as MD5, but it's not really suited for my purpose. I'm afraid I'm not much good at maths either...

MOD Of 1st 7digit = The 8th Digit Of A 8 Digit Number ?
Hi all,

I am new here and this forums is the best for VB, I use search a lot on this forum and always get what i am jamming at.
But after a whole days search, I am not able find this thing any where.

I have a text box which can take only 8 digits, the thing is, if the : MOD of 1st seven digit = 8th digit then it should focus on next fillup other wise prompt a msg of not been equal.

I know its not that hard for ppl around this great place.

Help would be really appreciated

Regards to all ..

Number Permutation

let say i have a number : 1234 , in this number, it can group to 1243, 1324, 1423, 1342 ... in 24 groups,

any formula to do this?

What Datatype To Use For 12 Digit Number?
The subject basically speaks for itself, What datatype can I use to work with 12 digit numbers?

EDIT: I have tried a single which doesnt produce the overflow error, but when looping through the rows in my spreadsheet, looking for a matching 12 digit number I get the type mismatch errors. Any suggestions please.

Random 29-Digit Number
Title explains it all. I just need to generate a random 29-Digit number and display it in text1.text.


Find A Digit In A Number
Hi to all:

I need to find a digit in a number like:


For example: I need to find the 5 digit (,) through a instruction

How can I do this?


3 Digit Number Adder
I'm working on this encyrption project, and I need to be able 2 add three numbers together that are separated by "."s.... heres an example:


I've forgotten all VB i used to know, so if someone could help me out, I would greatly appreciate it!

(btw, theres going 2 be alot of series.... so if you could make it still .611.290.399-only where the numbers are the previous numbers added 2gether(as u can see in the first #)) oh, and if any1 knows of a free vb compiler, i would greatly appreciate it!

or if ya could point me in the direction.... and i mean REALLY Point

hmm.. i think i'd have 2 split it up into sequences of 12 digits, and then tell it 2 add the 3 3digit sequences.... as for actually doing that tho, i have no clue...

Random 3 DIGIT Number
Well i have this code but it only generates a random 1 digit number.... now how can i do this code generate a 3 DIGIT number???

my code is

For x = 0 To 2
lblnumbers(x).Caption = Int(Rnd * 6)

Digit Grouping Of A Number
how to simultate digit grouping like in windows calculater or excel or something?

like 12000000 --> 12 000 000 or 12.000.000 . or _ = the character that is configured in windows.


Why Random 20 Digit Number Is Not Working
Ok I have tryed and tryed to make a 20 digit number random number but the number needs to have a number in front of it that the user sclects from a drop down box something like "01" "02" "03" "04" ok and so I tryed to do this

Private Sub Command1_Click()
Dim RandomNumber As String
RandomNumber = "01" & CStr(Int(Rnd * 99999999999999999999) -1)'also tryed + 1)
Text1.Text = RandomNumber & Int((Rnd * 99999999999999999999))
End Sub
but VB changes it to this
Private Sub Command1_Click()
Dim RandomNumber As String
RandomNumber = "01" & CStr(Int(Rnd * 2E+20) - 1)
Text1.Text = RandomNumber & Int((Rnd * 1E+20))
End Sub
and it out puts this
I only want a 20 digit number + 2 numbers the user sclects to come out to this
can any one help me here please
I read a lot of posts but none are like this lol I'm stumbed here

Helpp!! I Want To Swap 3 Digit Number
let say the input is 123
i want the output will be 321
which is rearranged from last digit to the first digit number

Choose A Fews Digit From A Number

The question is:

A have this code:


A want to put a Point "." to see the text box like this:


I had try wiht the Right and left instruction,but theses instructions just work with a group off numbers.


Get Most Significant Digit Of A Decimal Number?

Anyone know of a method of getting the most significant digit of a decimal number (i.e. the one at the left) other than converting it to a string?

1270 = 1
99 =9
212 = 1

Resolved Help - Displaying A 5 Digit Number

I have created a form which includes a txtbox for displaying info,
also I have a series of command buttons lets say 10 cmd buttons
each displaying a number ie similar to a cal. now my problem is
displaying a series of lets say 4 digit numbers.... the strange
thing is when I use the numpad everytin works fine but when
I use the command buttons it doesn't work... Has anyone any

Please help

Different Multi-digit Random Number Generator
i need smth that would generate a multi-digit
random number, differently each time i call the function
for ex,
23432423423-first call
234231111-second call
and when i exit hte program, and load again
874859435-first call
1231230202020-second call

complete randomization, no order,

is this possible?

Print Three Digit Number In Reverse Order
I need a Pascal program that will allow the user to enter a three digit number and the number will come out in reverse order. The reversed number needs to be a variable, and the numbers can't come out separately. I need this ASAP! Please help!!

Pascal: Printing 3-digit Number In Reverse Order
I need a Pascal program that allows the user
to enter a three-digit number and the number will print in reverse order. The reverse number should use a variable and it shouldn't print each of the digits separately.

Conversion Of Signed Digit To 8 Digit Hexadecimal In Vb6
Hi all,

i need to write a program which convert a signed digit to a 8 digit
If given a decimal number 100, i need to convert to hexadecimal as
How can i set the hexadecimal output to 8-digit?


I have to display all the permutation of n numbers.
For example for the first three number (1,2,3) they are:
The number of permutation for n numbers is n!
Is there an algoritm for this use?
Thanks for your answer

Permutation ?: Please Help A Newbie
I'm VERY NEW to VB. I'm generating a matrix of all possible feature sets for a new product. I'm using Excel to track the material cost and add'l overhead of each feature.

Here's the scenario:

I have six categories of features. They have varying numbers of items within them.

Category 1: 1,2,3,4
Category 2: 5,6,7
Category 3: 8,9,10
Category 4: 11,12,13
Category 5: 14,15
Category 6: 16,17

From each category, I must select exactly one item. I seek to generate a list of ALL possible options.

For Example:

Model 1: 1/5/8/11/14/16
Model 2: 2/5/8/11/14/16
Model 3: 3/5/8/11/14/16

et cetera

Any ideas? Any help would be GREATLY appreciated.

My Permutation Algorithm. Nearly There!
I tried to do it recursively before but that didn't work. Here's a graphical solution that nearly works.. can someone please read through and fix any logic problems? It's definitely on the verge of working!

Permutation Problems . . .
Hey all, it's been a while, but I'm back to working in VB. Now, sure enough, I've got another problem.
I'm writing a little program that will write all possible permutations of the given characters to a text file. The problem is, when I specify a minimum number of characters per line, and have more than one given character, a loop occurs. I have to forcefully shutdown the program, and the generated text file displays the same sequence of numbers over and over again . . .
Here's the code I use for calculating permutations:

txtMin is the minimum number of chars a line,
txtMax is the maximum number of chars a line,
and txtChars is a textbox containing all applicable characters.

Private Sub cmdCalculate_Click()

For tempvar = 1 To 20
Letter(tempvar) = Left$(txtChars.Text, 1)
LetterPosition(tempvar) = 1
Next tempvar

NumOfPerms = 0

Set A = CreateObject("Scripting.FileSystemObject")
Set Text = A.CreateTextFile(OutputFile, True)

For NumDigits = 1 To (Val(txtMax.Text) - Val(txtMin.Text))
finished = False
Do Until finished = True
LetterSequence = Empty
For tempvar = 1 To NumDigits
LetterSequence = LetterSequence + Letter(tempvar)
Next tempvar
Text.writeline LetterSequence: NumOfPerms = NumOfPerms + 1
For tempvar = 1 To NumDigits
If Letter(tempvar) <> Right$(txtChars.Text, 1) Then Exit For
If tempvar = NumDigits Then finished = True
Next tempvar
If chkBGprocesses.Value = 1 Then DoEvents
LetterPosition(NumDigits) = LetterPosition(NumDigits) + 1
If LetterPosition(NumDigits) = Len(txtChars.Text) + 1 Then
LetterPosition(NumDigits) = 1
For tempvar = 1 To (NumDigits - Val(txtMin.Text))
LetterPosition(NumDigits - tempvar) = LetterPosition(NumDigits - tempvar) + 1
If LetterPosition(NumDigits - tempvar) = Len(txtChars.Text) + 1 Then
LetterPosition(NumDigits - tempvar) = 1
Exit For
End If
Next tempvar
End If
For tempvar = Val(txtMin.Text) To NumDigits
Letter(tempvar) = Mid$(txtChars.Text, LetterPosition(tempvar), 1)
Next tempvar
Next NumDigits

MsgBox Str$(NumOfPerms) + " permutations derived."
End Sub
Can anyone see what the problem might be?
By the way, it works fine when I have a minimum of one, which makes me think that it has something to do with someplace that "Val(txtMin.Text)" is used. But as of yet I haven't been able to find the bug.

Gamer X

Permutation Algorithm

I am trying to work out a way to code a vba function that would accept an array of variables, for instance say a list of 20 names, from which you would input a number, say perhaps 5. And on this basis the function would generate a list of permutations based on all the possible combinations of 5 people from the list of 20. Is there some form of algorithm I should perhaps look at, or maybe it is more simple than I think it is.

Any help or pushes in the right direction would be greatly appreciated.

Array Permutation
I've searched the forum, i suppose you call this 'anagram', but all the examples i've found on this forum is with letters/strings
I have to do it with numbers, for example;

i have an array like this
and i want to find it's combinations


I want to write a routine to do this, but i don't know how to do it or how to modify the examples on this forum

the array's dimension is variable, for example it can be

Array Permutation
i have a tricky problem. i have for example three arrays of different dimestion

A =[1,2,3,4]

i would like to generate all the different combinations of values in these arrays and the values inside the array should not be repeated.

e.g. the resultset should be


any idea how to do this for any number N of arrays?

Permutation And Combination About The Particular Value
Suppose if we r giving any value like 100, what are the
permutations going to satisfy this value(100).

Combination / Permutation
How could I go about finding every different permutation of a string possible? Like, I want to be able to go through each possibility of a scrambled string:

abc goes to
abc, acb, bac, bca, cab, cba

All help is appreciated! Thanks!

Permutation Program
Hi! I am not good with math and I am making a permutation program. I am trying to list all the possible permutation in a listview but i am having trouble with the combination.. specifically how to swap the numbers. i am using the same concept as the one i read about in this link but this program uses notepad can anyone help me with this?

Having Difficulties With Permutation Function
Maybe its late in the day but I cant see how to do this. Ignore the actual application for this code but if anyone can help me come up with a function which will just output to the immediate window I can integrate it into the classes it needs to be in later (and of course I will be very greatfull).

The function has 2 inputs, 2 equal length strings of different charecters. I need to obtain every permutation in the correct order of the 2 strings

So if the inputs were "AB" and "CD", I would like to see the following output:


A 3 charecter example should produce the following results.

Inputs "ABC" and "DEF"

There may be more results that I didnt spot.

I hope ive explained myself properly, any help much appreciated.

Permutation Array Algorithm

I need generate all permutation array when the user type n ( n is natural number >0). When The user type for example n=4
I fill the first row and first column with the sequence {1,2,3,4}, if he typed n= 5 I fill with {1,2,3,4,5}
Example: for n=4
* |1234
1 |1234 -- First row
2 |2143
3 |3412
4 |4321

The number in the top and left are number of columns and rows . Look that First row is 1,2,3,4
and first column is 1,2,3,4
In the second column and row I have generate all
permutation possible, but the number only can to be one time in the column and one time in the row. ( the number 1 only one time in the column 1 , one time in the column 2 ...etc).
Other solution for n=4 is
* |1234
1 |1234
2 |2341
3 |3412
4 |4123

do somebody to know the algorithm that generate all
permutation possible without that number show more than one time in the column and row ?
I search abou derangement algorithm but I do not found.
I have to do this program in C or C++ or Pascal or Visual Basic

Thank You in Advance

im havng a problem figuring out how to extract all possible string combination with length n from a set of string... sori if im confusing here's an example
say collection {a,b,c,d} will produce

untill abcd

pls help

Edited by - kmarfilla on 7/6/2006 11:24:20 PM

Combination/permutation Type Problem
Hello everyone-

I write software where i have to display catogories on a screen (menus on a tv screen) that a user can navigate through. Currently i am implemnting new functionality that involves subscription based categories, so that only certain people who are entitled can view a particular category. There can be any number of subscription categories configured and the people should only see on the screen the cateogries that they are entitled to enter. So i need to create a screen for each unigue possible combination of these subscription cateogires on the screen.

So if i have 5 subscription categories configured, that means that i have (2 ^ 5) - 1 or 31 unique combinations of categories. If the category IDs are 10, 20, 30, 40, and 50 then these would be the 31 unique combinations:


The problem that i am having is how to figure out these combinations through code. For some reason my mind is drawing a complete blank today. I would greatly appreciate any help with this problem.


Permutation Function - Urgent ** Resolved
Hi all,

I Know what permutation & I know how to do this. But the thing is I am struggling to make it as a redursive function. Can anybody help me by providing some code which uses recursive logic to produce permutation for n digits.

I have an ex for 4 digit permutation without recursion. I request you people to pl convert this for n numbers in a recursive manner.

VB Code:
Dim I As Integer, J As Integer, K As Integer, L As IntegerFor I = 1 To 4    For J = 1 To 4        If Not (I = J) Then          For K = 1 To 4            If Not (K = J Or K = I) Then              For L = 1 To 4                If Not (L = I Or L = J Or L = K) Then Print I; J; K; L              Next L            End If          Next K        End If    Next JNext I

Tough Combinations Or Permutation Or Tree Or Subset Question
Allright. this one is getting to me now. I have a table that shows the neighbors of a cell. For example, my subject is ID 0. for ID 0 i have possible neighbors with IDS 48 498. Now I have a group of neighbor combinations i.e 0 48 and 0 498 and 0 48 498. Next i go to neighbors of ID 48. 48 has 3 neighbors first is ofcourse 0 and the other two are ID 498 and ID 23. Using ID 48 neighbors we get following set: 48 0; 48 498; 48 23; 48 498 23; 48 0 23 etc ettc. Now we also need our main subject ID 0 we now have the following possible combinations (including the original). i.e exclude anything that

[0 48; 0 498; 0 48 498; 0 48 23 (i.e since 498 is already included in original listi have to exclude it for this list).

I need to keep doing this recursively till i run out of neighbors. How would I accomplish this? I do have an exit in the sense that I have to evaluate values for a particular field for these neighbors and when that value crosses 35 i can exit and move to the next row.

I hope I have explained properly.


Last Digit
how can i get the last 2 digit of a number Ex: 12345 = "45"

All 6 Digit
is there a way have all 6 digit number possiblity, with 0 in front for example:
the zero in front is mainly my main in writing thing... can anyone help?

Last Digit
How can i get the lat 2 digit in a number like Ex: 3136 = "36"

60 Digit Calculator
Does anyone know, of how I can create a calculator that will add and subtract 60 digit integers. The integers must stay as whole 60 digits, and not as E..i.e. 121322e+12.
I have tried a simple + & - function, but i get an 'overflow' error.
Thx in advance for any help.

60 Digit Calculator
This is some code that i have written to add
two 60 digit numbers and leave a whole number response. However i can't seem to get it to work with my interface made up of two labels for the input and a text box for the output. Any help will be much apprieciated!!

Dim Num1(0 to 59) As Integer
Dim Num2(0 to 59) As Integer
Dim Result(0 to 60) as Integer
Dim Overflow as Boolean

For Digit=59 to 0 step -1
If TempNum>9 then
If Digit=0 Then
End If
End if
If Overflow=True Then
MsgBox("ERROR: Number is over the expected value")
End If

How To Check A Certain Digit??
Hi all, I am wondering how I can look at a specific spot in an integer. I have two text boxes, one being a date and the other being a time, and I want to check each digit in the integer of for example, 09:30, starting with the first digit, and check to see if it is > 1 and if so have a messege pop up stating it is an incorrect time.

Thanx everyone for the help!

Get Last Two Digit From Combo Box
I have record populate in the combo box for example 2007,2008,2009,2010,2011.

How I can get the last two digit from combo box and show it in the textbox?

Text6.Text = Combo6.Text

2 To 4 Digit Permutations
This is a mini experiment I would like to try out. I had created 4 textboxes joined together, "Text1 to Text4", an "Enter" command button by the text boxes, a "2 number Text" command button, a "3 number Text" command button, a reset command button and an Exit button, all separated by a space one by one below. (The command buttons are the same size as each other.) The space below the 4 joint text boxes is the most puzzling among them all, the Label. I will explain my objective and then the questions:

a) The 4 textboxes are supposed to display numbers between 0 to 9, no letters and no numbers smaller than 0 or bigger then 9. (This part is solved.)

b) When I clicked on the "2 number text" command button, the "3 number text" command button is disabled and Text3 and Text4 are invisible .
When I clicked on the "3 number text" command button, the "2 number text" command button is disabled and Text4 is invisible.
When I clicked Enter without any selection, "2 number text" and "3 number text" command buttons are disabled, assuming that I wanted to input all 4 digits. (These parts are solved.)

c) The Reset button resets all the conditions back to normal. Text1 to Text 4 boxes will be resetted back to "0" with all the 4 Text boxes available (visible) and the 2 common buttons ("2 number text" button and "3 number text" button) made enabled. The exit button quits the programme, as usual. (This part is also solved.)

Now, the question :

1) Notice that there is an empty space under the 4 textboxes? That is for the label to cover the rest of the display. That is the place where I want the enter button to output the permutation. The problem now is how do I write the permutation in the Label after I input my 2 to 4 numbers and pressed enter? Also take in account that the number I planned to input is also supposed to be one of the selected choices. (Example: If I want 0 and 1 as my 2 numbers, "01" and "10" are supposed to be displayed in the label as 2 permutations, not just 10.) Please help me to write a clear display function for the label when I press the reset command button.

2) I wanted only one digit to display in my text boxes but I do not know how to do that.(eg. 09 is also less than 10.) Can anyone help?

For those who have no idea how the display looks like, just imagine it like this display message page. Close current Tag, close all tags and the smilies on the right are the 5 command buttons. The dropdown boxes, option functions and guided mode is roughly the length of the textboxes, number size, 4 of them. This big textbox is something like the label, to store the 1 to 24 permutations.

I hoped that my explanations and the layouts are clear to you guys. Please help. Thanks!!!

Get 6 Digit Permutations
Basically I need to get every 6 digit permutation which only uses three numbers:

3, 5, 2

Don't know why I can't figure it out on my own, I've done something similar to this before.

Four Digit Numbers
I want it so that when the user presses Command1 it adds the numbers 1 - 9999 and txtWord.text to lstFound, the problem is I want it to add, say for the first ten, this :


I was thinking of, depending on the length of x, it adds 4 - x zeroes with a loop, but I dont know how to determine the length. All help is appreciated.

- Steve

Mod 11 Check Digit
Does anyone have a block of VB code to do a Mod 11 Check Digit? Thanks.

Is Charecter Is Digit?
How can i find if a charector is a ditit?

Copyright 2005-08, All rights reserved