When I try to run this code (thanks to MartinLiss for the Replacetext Function), I get an error about Parameter Type Mismatch.
I've tried running the module with actually text like:
And that works fine.Code:x = Replacetext("Hello There", "ello", "i")
I've really never used functions before, but from what I've looked up, I'm doing it right. What's wrong?
Thanks,
JazzBass
Code:Sub Command1_Click Dim sString, sFind, sReplace As String sString = InputBox$("Please enter some text") sFind = InputBox$("Please enter the text you want to replace from " & sString) sReplace = InputBox$("Please enter the text you want to replace from " & sString) x = ReplaceText(sString, sFind, sReplace) msg = "The starting string was: " & sString msg = msg & Chr$(13) & Chr$(10) & "The string to find was: " & sFind msg = msg & Chr$(13) & Chr$(10) & "The string to replace was: " & sReplace ' msg = msg & Chr$(13) & Chr$(10) & Chr$(13) & Chr$(10) & "The New String is: " & sNewText End Sub
In Module:
[Edited by JazzBass on 04-18-2000 at 10:23 AM]Code:Function ReplaceText (sString As String, sFind As String, sReplace As String) As String Dim intPos As Integer intPos = 999 If sFind <> sReplace Then Do Until intPos = 0 intPos = InStr(1, sString, sFind) If intPos > 0 Then sString = Left$(sString, intPos - 1) & sReplace & Right$(sString, Len(sString) - intPos - Len(sFind) + 1) End If Loop End If sNewText = sString End Function






Reply With Quote