If you don't have VB6, here is the VB5 eqv.
Code:Public Function Replace(sIn As String, sFind As String, _ sReplace As String, Optional nStart As Long = 1, _ Optional nCount As Long = -1, Optional bCompare As _ VbCompareMethod = vbBinaryCompare) As String Dim nC As Long, nPos As Integer, sOut As String sOut = sIn nPos = InStr(nStart, sOut, sFind, bCompare) If nPos = 0 Then GoTo EndFn: Do nC = nC + 1 sOut = Left(sOut, nPos - 1) & sReplace & _ Mid(sOut, nPos + Len(sFind)) If nCount <> -1 And nC >= nCount Then Exit Do nPos = InStr(nStart, sOut, sFind, bCompare) Loop While nPos > 0 EndFn: Replace = sOut End Function




Reply With Quote