|
-
Aug 24th, 2001, 08:49 AM
#1
Thread Starter
Addicted Member
Simple Find and Replace
I want to do a simple find and replace but I cannot get this to work with variables using the Replace() Function:
sLine = "Wednesday 15/08/01"
sOldDate = Trim(Mid(sLine, 11, 8))
sNewDate = Date
sLine = Replace(sLine, sOldDate, sNewDate)
Can someone show me how I can get this to work ?
-
Aug 24th, 2001, 08:52 AM
#2
Try this:
Private Function ReplaceAll(SourceString As String, ReplaceThis As String, WithThis As String)
Dim Temp As Variant
Temp = Split(SourceString, ReplaceThis)
ReplaceAll = Join(Temp, WithThis)
End Function
'To call: ReplaceAll(txtSomeTextBox.Text, "OldString", "NewString")
-
Aug 24th, 2001, 08:54 AM
#3
PowerPoster
I think this is what you're getting at:
VB Code:
Dim sLine As String
Dim sOldDate As String
Dim sNewDate As String
sLine = "Wednesday 15/08/01"
sOldDate = Trim(Mid(sLine, 1, Len(sLine)))
sNewDate = CStr(Format(Date, "dddd dd/mm/yy"))
sLine = Replace(sLine, sOldDate, sNewDate)
MsgBox sLine
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|