Handling Notepad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sameerkhan
    New Member
    • Nov 2006
    • 6

    Handling Notepad

    Hi,

    Could anyone send me code for following problem..

    I have two text files, one containing list of names another is a log file containing error description.

    I have to find error description from log file for every names in first text file. And i have to copy the description to the first file.

    If you able send code for following scenario that wud be fine.

    Finding text in notepad (have to get line number).
    copying text in particular line and place from notepad.
    writing text to particular line.
    looping though each line in notepad.

    Thanx in Advance.
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Do you need to specifically use Notepad, or are you just referring to text files? Doing this sort of thing from VB code will be fairly simple, but if your program has to drive the Notepad application, that will complicate things.

    Is this for an assignment? What version of VB are you using?

    Comment

    • sameerkhan
      New Member
      • Nov 2006
      • 6

      #3
      Originally posted by Killer42
      Do you need to specifically use Notepad, or are you just referring to text files? Doing this sort of thing from VB code will be fairly simple, but if your program has to drive the Notepad application, that will complicate things.

      Is this for an assignment? What version of VB are you using?

      I just referred Text Files. I am using Visual Basic 6.0. Pls send me code to handle text files.

      Comment

      • vijaydiwakar
        Contributor
        • Feb 2007
        • 579

        #4
        Originally posted by sameerkhan
        Hi,

        Could anyone send me code for following problem..

        I have two text files, one containing list of names another is a log file containing error description.

        I have to find error description from log file for every names in first text file. And i have to copy the description to the first file.

        If you able send code for following scenario that wud be fine.

        Finding text in notepad (have to get line number).
        copying text in particular line and place from notepad.
        writing text to particular line.
        looping though each line in notepad.

        Thanx in Advance.
        see there is one tech i.e. world wide accepted and that is create ErrorLog tbl in ur db and the problem will be get solved
        try it

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by vijaydiwakar
          see there is one tech i.e. world wide accepted and that is create ErrorLog tbl in ur db and the problem will be get solved
          try it
          Who said anything about a database?

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Originally posted by sameerkhan
            I just referred Text Files. I am using Visual Basic 6.0. Pls send me code to handle text files.
            I think you will need to look up information and experiment for yourself, but we can help steer you in the right direction.

            For a start, there are two main methods commonly used for dealing with text files in VB6.
            1. The simple, built-in method using Open, Line Input #, Print #, Write #, Get, Put and Close statements.
            2. The slightly more complex, but more powerful FileSystemObjec t. To use this one you have to add the Microsoft Scripting Runtime to your project, under Project | References.
            You should investigate these (start with the Open and Line Input statements for the former) and decide for yourself which is a better match for your needs.

            Comment

            • sameerkhan
              New Member
              • Nov 2006
              • 6

              #7
              Originally posted by Killer42
              I think you will need to look up information and experiment for yourself, but we can help steer you in the right direction.

              For a start, there are two main methods commonly used for dealing with text files in VB6.
              1. The simple, built-in method using Open, Line Input #, Print #, Write #, Get, Put and Close statements.
              2. The slightly more complex, but more powerful FileSystemObjec t. To use this one you have to add the Microsoft Scripting Runtime to your project, under Project | References.
              You should investigate these (start with the Open and Line Input statements for the former) and decide for yourself which is a better match for your needs.
              Yes Killer you got my problem exactly,

              I have already got solution for my problem by using FileSystemObjec t. But i have write my own logic to implement this. I just want to know whether any direct and easy method to do the same.

              I wl narrate my requirment in details

              I have text file with some name list as follows.

              0400933313
              0400934041

              and there is one text file which has error description with it as follows.

              2007-03-12-17:59:27 Tiff file [44.TIF] has incorrect format.
              2007-03-12-17:59:27 Error in document. [0400933313__DOC A]
              2007-03-12-17:59:27 Error in batch. [0400933313.ddf]
              2007-03-12-17:59:27 Problem processing directory. [0400933313]

              I have to copy the description in first line 'Tiff file [44.TIF] has incorrect format' to my text file as follows

              0400933313 Tiff file [44.TIF] has incorrect format

              P.S. Error description can be find in more than one place, i need to get latest(last) description.

              Hope i am clear now. if this can be done directly using any function pls send it to me.

              Thanx in Advance.

              Comment

              • Killer42
                Recognized Expert Expert
                • Oct 2006
                • 8429

                #8
                I don't actually understand your question very well. However, in this part...
                Originally posted by sameerkhan
                ...
                2007-03-12-17:59:27 Tiff file [44.TIF] has incorrect format.
                2007-03-12-17:59:27 Error in document. [0400933313__DOC A]
                2007-03-12-17:59:27 Error in batch. [0400933313.ddf]
                2007-03-12-17:59:27 Problem processing directory. [0400933313]

                I have to copy the description in first line 'Tiff file [44.TIF] has incorrect format' to my text file as follows

                0400933313 Tiff file [44.TIF] has incorrect format
                ...how do you know what user ID the error message relates to?

                In any case, if you have something that works using FileSystemObjec t, I would stay with that. Using Open/Close may make your code very slightly simpler, but that doesn't necessarily mean it's any better.

                I don't know of any way to automate this kind of thing - you would just need to work out the logic to achieve your goal, then encode it in the programming language. It sounds as though you have already done that.

                Comment

                Working...