V
VB Programmer
I am trying to create a function which strips out ALL occurances of a
particular phrase in a string. It returns the cleaned up string. I gave it
an argument of "1###2###3###4". When it finally gets to the Return
statement it DOES return the correct thing, but by the time it finally
"unravels" it returns nothing. Any ideas????
Private Function StripOutPounds(ByVal strMsg As String) As String
Try
Dim s As String
' strip out every occurance of "###"
If strMsg.IndexOf("###") <> -1 Then ' if an occurance exists
' get everything to the left
s += strMsg.Substring(0, strMsg.IndexOf("###"))
' get everything to the right
s += strMsg.Substring(strMsg.IndexOf("###") + 4)
s = StripOutServerMessage(s)
Else ' return cleaned up message
Return strMsg
End If
End Function
particular phrase in a string. It returns the cleaned up string. I gave it
an argument of "1###2###3###4". When it finally gets to the Return
statement it DOES return the correct thing, but by the time it finally
"unravels" it returns nothing. Any ideas????
Private Function StripOutPounds(ByVal strMsg As String) As String
Try
Dim s As String
' strip out every occurance of "###"
If strMsg.IndexOf("###") <> -1 Then ' if an occurance exists
' get everything to the left
s += strMsg.Substring(0, strMsg.IndexOf("###"))
' get everything to the right
s += strMsg.Substring(strMsg.IndexOf("###") + 4)
s = StripOutServerMessage(s)
Else ' return cleaned up message
Return strMsg
End If
End Function