By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,798 Members | 1,378 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,798 IT Pros & Developers. It's quick & easy.

Handling Notepad

P: 6
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.
Mar 14 '07 #1
Share this Question
Share on Google+
7 Replies


Expert 5K+
P: 8,434
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?
Mar 14 '07 #2

P: 6
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.
Mar 15 '07 #3

vijaydiwakar
100+
P: 579
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
Mar 15 '07 #4

Expert 5K+
P: 8,434
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?
Mar 15 '07 #5

Expert 5K+
P: 8,434
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 FileSystemObject. 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.
Mar 15 '07 #6

P: 6
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 FileSystemObject. 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 FileSystemObject. 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__DOCA]
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.
Mar 16 '07 #7

Expert 5K+
P: 8,434
I don't actually understand your question very well. However, in this part...
...
2007-03-12-17:59:27 Tiff file [44.TIF] has incorrect format.
2007-03-12-17:59:27 Error in document. [0400933313__DOCA]
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 FileSystemObject, 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.
Mar 19 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.