Листинг 4. Варианты реализация функции Replace традиционными средствами Basic
Приложение к статье"Разбор полетов"


Function ReplaceMy$(Source$, LookFor$, ReplaceWith$)  
'
'  Контекстная замена кода строки
'===================================  
  Dim strTemp$, iStart%, iStrLen%  
  strTemp$ = Source$  
  If Len(strTemp$) > 0 Then  
    iStart% = 1  
    iStrLen% = Len(ReplaceWith$)  
    Do  
      iStart% = InStr(iStart%, strTemp$, LookFor$)  
      If iStart% = 0 Then Exit Do  
      strTemp$ = Left$(strTemp$, iStart% - 1)  +  _  
        ReplaceWith$ + Mid$(strTemp$, iStart% + Len(LookFor$))  
      iStart% = iStart% + iStrLen%  
    Loop  
  End If  
  ReplaceMy$ = strTemp$  
End Function

В начало статьи