craigachan
Registered User.
- Local time
- Today, 15:59
- Joined
- Nov 9, 2007
- Messages
- 285
I've written a function that takes a person's name and gets rid of all periods, spaces, commas, and appostrophies. When I run the code outside of a function it works. but when I put it in a public function, somehow I get a compile error. I just can seem to figure it out. Can anyone tell me what I'm doing wrong? Here is the code:
Public Function FixPtSaveName(strSaveName As String)
On Error GoTo FPS_Err
Dim x As Integer
Dim ct As Integer
Dim strFName As String
ct = Len(strSaveName)
strFName = ""
For x = 1 To ct
If Mid(strSaveName, x, 1) <> " " Then
If Mid(strSaveName, x, 1) <> Chr(46) Then
If Mid(strSaveName, x, 1) <> "," Then
If Mid(strSaveName, x, 1) <> "'" Then
strFName = strSaveName & Mid(strSaveName, x, 1)
End If
End If
End If
Else
strFName = strFName
End If
Next x
FPS_Err:
MsgBox "OOPS"
Resume FPS_Exit
FPS_Exit:
Exit Function
End Function
This code runs until it finishes the last character then errors out. It's probably something real simple but I've been pulling my hair out.
thanks for the help.
Public Function FixPtSaveName(strSaveName As String)
On Error GoTo FPS_Err
Dim x As Integer
Dim ct As Integer
Dim strFName As String
ct = Len(strSaveName)
strFName = ""
For x = 1 To ct
If Mid(strSaveName, x, 1) <> " " Then
If Mid(strSaveName, x, 1) <> Chr(46) Then
If Mid(strSaveName, x, 1) <> "," Then
If Mid(strSaveName, x, 1) <> "'" Then
strFName = strSaveName & Mid(strSaveName, x, 1)
End If
End If
End If
Else
strFName = strFName
End If
Next x
FPS_Err:
MsgBox "OOPS"
Resume FPS_Exit
FPS_Exit:
Exit Function
End Function
This code runs until it finishes the last character then errors out. It's probably something real simple but I've been pulling my hair out.
thanks for the help.