Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


List of possible combinations for x numbers.


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-06-2007, 05:19 PM
EdQas's Avatar
Junior Member
 
Join Date: Aug 2007
Location: French Riviera
Posts: 35
Red face List of possible combinations for x numbers.

Hi everybody,
If I have 3 numbers, the list of all combinations is :
3*2*1 = 6 possibilities :
123 132 213 231 312 321

If I have 7 numbers, there are 5040 possibilities (7*6*5*4*3*2*1).

: how can i list all of these possibilities ?

Thank you for the help.

Ed
__________________

Dell Axim x51v
Reply With Quote
  #2 (permalink)  
Old 10-06-2007, 06:04 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 2,811
Default

Do you mean something like:
Code:
Sub App_Start
    Msgbox(Factorial(7))
End Sub

Sub Factorial(n)
    f = 1
    For i = 2 To n
        f = f * i
    Next
    Return f
End Sub
Reply With Quote
  #3 (permalink)  
Old 10-06-2007, 06:12 PM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 575
Default

I think he is looking for something like this:

Code:
Sub Globals
End Sub

Sub App_Start
    ' Create a Form1 and add a ListBox1
    FillListBox("1234567", "")
    Form1.Show
    Msgbox(ListBox1.Count)	
End Sub

Sub FillListBox(value, combi)
    If value = "" Then
        ListBox1.Add(combi)
    Else
        For i = 0 To StrLength(value) - 1
            FillListBox(StrRemove(value, i, 1), combi & SubString(value, i ,1))		
        Next
    End If
End Sub

specci48
Reply With Quote
  #4 (permalink)  
Old 10-07-2007, 09:18 AM
EdQas's Avatar
Junior Member
 
Join Date: Aug 2007
Location: French Riviera
Posts: 35
Thumbs up Hurra !

Thank your Erel and Specci !
The example of Specci was what i was searching for.
Once more, many thanks.
Have a nice sunday.
Ed
__________________

Dell Axim x51v
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Numbers lock key davelew1s Questions & Help Needed 0 06-14-2008 07:26 PM
Combinations application Stellaferox Share Your Creations 0 02-21-2008 08:24 PM
Combinations Sub: choose(n,k) Stellaferox Code Samples & Tips 2 02-21-2008 06:51 PM
Combinations function derez Share Your Creations 0 02-04-2008 11:40 AM
code to write out combinations e.g. (10 choose 3) Stellaferox Questions & Help Needed 4 02-04-2008 05:51 AM


All times are GMT. The time now is 04:23 AM.


Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0