Public Function ReplaceText(ByVal txt As String, ByVal from_str As String, ByVal to_str As String) As String Dim result As String Dim from_len As Integer Dim pos As Integer from_len = Len(from_str) Do While Len(txt) > 0 pos = InStr(txt, from_str) If pos = 0 Then result = result & txt txt = "" Else result = result & Left$(txt, pos - 1) & to_str txt = Mid$(txt, pos + from_len) End If Loop ReplaceText = result End FunctionUse : Replace(text1.text,"a","b")
ไม่มีความคิดเห็น:
แสดงความคิดเห็น