dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Find & Replace using VB 6.0

  1. #1
    Join Date
    Dec 2003
    Posts
    52

    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?

  2. #2
    Join Date
    Dec 2010
    Posts
    4

    Thumbs up Replace

    Use Replace function, I beleave that you not to know this function

  3. #3
    Join Date
    Dec 2003
    Posts
    52
    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"

  4. #4
    Join Date
    Dec 2010
    Posts
    4

    Question 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

  1. Replies: 5
    Last Post: 04-17-2008, 01:22 PM
  2. How do you create a file system object in vb srcipt or vb 6.0
    By Michael Kascher in forum VB Classic
    Replies: 3
    Last Post: 09-01-2006, 03:15 PM
  3. Replies: 84
    Last Post: 01-29-2001, 02:12 PM
  4. Re: VB or Powerbuilder?
    By Jean-Yves in forum Enterprise
    Replies: 3
    Last Post: 06-01-2000, 12:23 PM
  5. How do you create a file system object in vb srcipt or vb 6.0
    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center