Private Function FindReplace(sText As String, sFind As String, _
sReplace As String) As String Dim n%, c%'declare Integer variables Dim sTempR$, sTempL$ 'declare temporary variables to peice together 'the finished product c = 1 n = 1 Do c = InStr(n, sText, sFind) 'locate the String you want to replace If c% <> 0 Then 'if it's found then sTempL = Mid$(sText, 1, c - 1) 'grab the contents to the left of the found String sTempR = Mid$(sText, c + Len(sFind)) 'grab contents to the right of the foundstring sText = sTempL & sReplace & sTempR 'peice the contents of the left and the right End If 'together With the word you want to replace in n = c + 1'the middle Loop Until c = 0 FindReplace = sText End Function Private Sub Command1_Click() Text1.Text = FindReplace(Text1.Text, Text2.Text, Text3.Text) 'call it like this End Sub |