因为操作字符串经常会需要替换指定字串,但是fb的内置函数没有发现能实现的,所以自己写了个。
''替换字符串中的指定子串
Function StringReplace(sString As String, searchstring As String, replacestring As String) As String
Dim As Integer p = InStr(sString, searchstring)
Dim As String s = Mid(sString, 1, p-1) & replacestring & Mid(sString, p + Len(searchstring))
Do While p <> 0
p = Instr(p + 1 + Len(searchstring), s, searchstring)
If p = 0 Then Exit Do
s = Mid(s, 1, p-1) & replacestring & Mid(s, p + Len(searchstring))
Loop
Return s
End Function
''使用示例,把IP地址中的.替换成空格
?StringReplace("255.255.255.255", ".", " ")
|
阅读(1098) | 评论(0) | 转发(0) |