| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
||||
|
||||
|
A 'strReplace' function.
Private Sub Command1_Click()
Dim oldstring As String, newletter As String, oldletter As String, newstring As String oldstring = "hello To the world" newletter = "YEAH" oldletter = "hello" newstring = Replace(oldstring, newletter, oldletter) MsgBox newstring End Sub Public Function Replace(oldstring, newletter, oldletter) As String Dim i As Integer i = 1 Do While InStr(i, oldstring, oldletter, vbTextCompare) <> 0 Replace = Replace & Mid(oldstring, i, InStr(i, oldstring, oldletter, vbTextCompare) - i) & newletter i = InStr(i, oldstring, oldletter, vbTextCompare) + Len(oldletter) Loop Replace = Replace & Right(oldstring, Len(oldstring) - i + 1) End Function |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > A 'strReplace' function. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|