-
Find & Replace using VB 6.0
I am developing a program in VB 6 to replace a value in a text file. I have 2 text files. I need to open the 1st text file(X1.txt), get the date from this file. Then open the 2nd text file(X2.txt) and replace the date in the 2nd file with the date I got from the 1st text file.
I have the code for the 1st section
Open strSource & "X1.TXT" For Input As #X
Do While Not EOF(X)
Line Input #X, strLine
If strLine Like "*##/##/####*" Then
For R = 1 To Len(strLine)
If Mid$(strLine, R, 10) Like "*##/##/####*" Then date from the source file.
strLine = Mid$(strLine, R, 10)
strSourceDate = Trim(strLine): Exit Do
End If
Next
End If
Loop
The string “strSourceDate” has the date from the 1st text file. I want to replace the date in the 2nd file, with this date. The 2 files have the same format and data.
How do I do this?
-
Replace
Use Replace function, I beleave that you not to know this function
-
I tried the REPLACE function and still not working. I have the code as below
Open strDest & "Y1.TXT" For Input As #Y
Do While Not EOF(Y)
Line Input #Y, strLine
If strLine Like "*##/##/####*" Then
For R = 1 To Len(strLine)
If Mid$(strLine, R, 10) Like "*##/##/####*" Then
strDestDate = Mid$(strLine, R, 10)
xx = Replace(strLine, strDestDate, strSourceDate)
End If
Next
End If
Loop
I want to replace the date in "strDestDate" with the date in "strSourceDate" in the line "strLine"
-
Replace
I dont know your "strSourceDate" but replace command Replace("xxx10/12/2009yyy","10/12/2009","24;12;2009") result in xxx24;12;299yyy.
You use xx=replace(strline,...
Use strline = replace(strline,....
or
put after xx=
Debug.print strLine
Debug.print strDestDate
debug.print strSourceDate
Debug.print xx
Close
End
Show me result ....
Similar Threads
-
By awyeah in forum VB Classic
Replies: 5
Last Post: 04-17-2008, 01:22 PM
-
By Michael Kascher in forum VB Classic
Replies: 3
Last Post: 09-01-2006, 03:15 PM
-
By Jon Ogden in forum .NET
Replies: 84
Last Post: 01-29-2001, 02:12 PM
-
By Jean-Yves in forum Enterprise
Replies: 3
Last Post: 06-01-2000, 12:23 PM
-
By Michael Kascher in forum VB Classic
Replies: 2
Last Post: 05-31-2000, 02:48 PM
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
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|