LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Recursive To non-Recursive Procedure

Can anybody convert this recursive procedure to a non-recursive one?
========================================
Sub Permutation(Str1 As String, _
Optional Str2 As String = vbNullString, _
Optional ByRef Xrow As Long = 1)
Dim i As Integer, xLen As Integer, a As String, b As String

xLen = Len(Str1)
If xLen < 2 Then
Range("A" & Xrow) = Str2 & Str1
Xrow = Xrow + 1
Else
For i = 1 To xLen
a = Left(Str1, i - 1) & Right(Str1, xLen - i)
b = Str2 & Mid(Str1, i, 1)
Call Permutation(a, b, Xrow)
Next
End If

End Sub
========================================

The procedure is called, in the simplest way, with:
Call Permutation("string-to-permute").

Bruno
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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
Recursive Functions...maybe busboy10 Excel Worksheet Functions 0 March 28th 11 09:46 PM
Is this a recursive problem? davegb Excel Programming 2 August 16th 06 07:53 PM
Recursive Code Myles[_68_] Excel Programming 1 August 13th 06 02:11 PM
Help with Recursive Call? mark Excel Programming 9 May 25th 06 08:44 PM


All times are GMT +1. The time now is 03:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"