Error handler can't handle mystery error
Posted on 1999-07-15
I have a search-and-replace function that worked fine until
it broke. I added an error handler so now it looks like:
Function Replace(txtMain As String, txtSearch As String, txtReplace As String)
On Error GoTo Trap
Dim FoundAt As Integer
Dim txtWork As String
txtWork = txtMain
FoundAt = InStr(FoundAt + 1, txtWork, txtSearch)
txtWork = Left$(txtWork, FoundAt - 1) & txtReplace & Mid$(txtWork, FoundAt + Len(txtSearch))
Loop While (InStr(FoundAt + 1, txtWork, txtSearch) <> 0)
Replace = txtWork
MsgBox "Replace error" & Str(Err.Number) & ": " & Err.Description, , "Error"
The message this generates is:
"Replace error 0:"
What is error #0 and why does it have no description?