Hi -
I've just started playing with recursive fuctions, and admittedly I'm struggling just a tad.
Here's a non-recursive function I wrote to remove unwanted characters from a string.
Anyone up to a challenge of rewriting this as a recursive function:
	
	
	
		
It works spiffy as written, but I played with it (and bombed) trying to convert it as a recursive function.
There's no desperation in my request--no 'I have to turn this in my 09:00 tomorrow', just a desire to see how it might work.
Any suggestions greatly appreciated.
Best wishes - Bob
 I've just started playing with recursive fuctions, and admittedly I'm struggling just a tad.
Here's a non-recursive function I wrote to remove unwanted characters from a string.
Anyone up to a challenge of rewriting this as a recursive function:
		Code:
	
	
	Public Function fFixWords3(pStr As String) As String
'------------------------------------------------------------------
' Purpose:   Remove non-Alpha/non-numerical characters from a string
' Coded by:  raskew
' Arguments: pStr: The string to be searched.
' Input: from debug (immediate) window
'              ? fFixWords3("132$/8 AS-01-HO1 ")
' Output:      1328AS01HO1
'------------------------------------------------------------------
Dim strHold As String
Dim strKeep As String
Dim chrHold As String
Dim intLen As Integer
Dim n As Integer
    strHold = Trim(pStr)
    intLen = Len(strHold)
    For n = 1 To intLen
       chrHold = UCase(Left(strHold, 1))
      'the following accepts (A - Z) and/or (0 - 9), exclusively
       If Asc(chrHold) >= 65 And Asc(chrHold) <= 90 Or Asc(chrHold) >= 48 And Asc(chrHold) <= 57 Then
          strKeep = strKeep & chrHold
       End If
       strHold = Mid(strHold, 2)
    Next n
    fFixWords3 = strKeep
End Function
	It works spiffy as written, but I played with it (and bombed) trying to convert it as a recursive function.
There's no desperation in my request--no 'I have to turn this in my 09:00 tomorrow', just a desire to see how it might work.
Any suggestions greatly appreciated.
Best wishes - Bob
			
				Last edited: