VB help

Associate
Joined
11 Nov 2003
Posts
860
Location
South London
Hi,

I'm trying to call a function in a procedure to remove bad characters from a string. For some reason when I call the function it is just returning an empty string, rather than the output from the function. Code is below.

Any idea what I'm doing wrong?

Fred

Code:
Private Sub test()

Dim strMsg As String

strMsg = removeBadChar("Aus/NZ", "/", "")

MsgBox (strMsg)

End Sub

Public Function removeBadChar(StrInputString, StrSearchPattern, StrReplacePattern As String) As String

Dim i As Integer

Do While InStr(LCase(StrInputString), StrSearchPattern)
   i = InStr(LCase(StrInputString), StrSearchPattern)
   StrInputString = Mid(StrInputString, 1, i - 1) & StrReplacePattern & Mid(StrInputString, i + Len(StrSearchPattern), Len(StrInputString))
Loop

End Function
 
Back
Top Bottom