#include once "window9.bi"
Function ReplaceString(ByVal String_ As string,byval SearchString As String,byval ReplaceString_ As String,ByVal Position As Integer=1,ByVal searchParam As Integer=0, ByVal RegisterParam As Integer=0) As String Export
  Dim As String tempString_ , Returnstring=String_
  Dim As Integer Possearch,possearchnext=Position,pos0 =1
  Do
    If RegisterParam=0 Then
      Var RS=Returnstring,SS=SearchString
      CharLower(RS):CharLower(SS)
      Possearch=InStr(possearchnext,RS,SS)
    Else
      Possearch=InStr(possearchnext ,Returnstring,SearchString)
    end if
    If Possearch<>0 Then
      tempString_= Mid(Returnstring,pos0,Possearch-1) & ReplaceString_ & Mid(Returnstring,Possearch+Len(SearchString))
      If searchParam=1 Then
        Returnstring=tempString_
        possearchnext=Possearch+Len(ReplaceString_)
      Else
        Return tempString_
      End If
    Else
      Return Returnstring
    End If
  Loop
End Function
