Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Read Line By Line Of Text File And Move Content To Excel Record By Record


Hi,
   i am trying to move the selective information in the text file to Excel sheet record by record using VB.Can u help me in this regard.

The contents in text file is like:

"http://www.commerx.com/contact.html","inforequest@commerx.com"
"http://www.commerx.com/contact.html","ClientSupport@commerx.com"
"http://www.commerx.com/services-intranets.html","intranets@commerx.com"
"http://www.davacosourcing.com/company/","bignews@davacosourcing.com"
"http://www.davacosourcing.com/company/","careers@davacosourcing.com"
.
.
.
.
.
.

The above information need to be moved in Excel sheet record by record as:                    
http://www.commerx.com/contact.html        inforequest@commerx.com    
http://www.commerx.com/contact.html        ClientSupport@commerx.com    
http://www.commerx.com/services-intranets.html    intranets@commerx.com    
http://www.davacosourcing.com/company/ bignews@davacosourcing.com
http://www.davacosourcing.com/company/ careers@davacosourcing.com
.
.
.
.
..

Please do help in this regard as there are more than 1000 information that has to moved in the above pattern.

Thanx
babu


 




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Read Rich Text Box Content Line By Line
Hi all. I got a rich text box and i wonder how i can read each line of it one by one. For example i want to read each line of it and display it in massage box.
Furthermore, if i have 10 line of content in textbox how i can refrence each line and display it in massage box?

I be happy if some one show me how this can be done.Thanks

Line By Line Text File Read And Correct Each Line
Can anyone help me create a small program or have any pointers
on pieces of code that reads a text file from folder "unfixed" then
fix the contents and then store the corrected contents
in another folder "fixed" and then move the file in folder "unfixed" to folder "old"

Details of contents.
There is a space infront of each line that should be removed.
Between the first group of numbers and the second there should be a zero for every space.
Then after the second group of numbers there should be just one space and the rest trimed off.


011531015222360000500355 3350505212004 50122
011531015222360000500363 5336305212004 6255
011531015222360000503465 2404505212004 50022
011531015222360000503463 1345205212004 50025
02153101522236 13 1503256


The @ symbol represents where a space should be.
I would like to read the file and then correct it and then
place the fixed contents in another folder with the original name.
Below is how I would like it to look.

01153101522236000050035500000003350505212004@
01153101522236000050036300000005336305212004@
01153101522236000050346500000002404505212004@
01153101522236000050346300000001345205212004@
021531015222360000000013@

Read, Find A Line And Delete The Line In Text File
Hi, I am writing codes to do the following things: read a line from a text file, if this is a matched line, delete the line and go to the next line.

Can any one give me some direction? Such as access mode, method to use, etc.

Thanks.

.Input ( Read Contentsof Text File - Line By Line )
I'm trying to import Data from a text file, which includes the following,

Vessel Name
000115600
000025600
000000000
000089000
000019000
000000000
6670.43

The above file is updated every five minutes and I wish to retreive this data in
order to perform calc's and then display a completion time for a process on the
User Form.

code:-----------------------------------------------------------------------------
---
Open "YourFile.txt" For Input As #1
While Not EOF(1)
Input #1, YourVariable
List1.Additem YourVariable
Wend
Close #1
--------------------------------------------------------------------------------

Instead of adding to a list as in the above example, I want to process it Line by
Line ( How do I achieve this using .Input ).

Help

How Can I Read Only One Line Or Specific Line Of A Text File
How can i read only one line or specific line of a text file?

How To Read Text File Line By Line?
Dears Friends,
I am coding a program to read emails.
Is there a way to read the email body text line by line ? if not possible, how can I set the bodytext to a text file and use that text file to read line by line?

Here is my psuedocode for reading email line by line:

With .bodytext
Loop from line 1 to EOF
If line x has string "Hello" then
If line x + 1 has "Money" then
forward this to youare@somewhere.com
end if
end if
End loop
End with

Here is my psuedocode for set .bodytext to file.
dim sFirststring as string
dim sSecondstring as string
With .bodytext
save the .bodytext to a file name A.txt
sFileName = " C:A.txt"
Open sFileName For Input As #1
Do Until EOF(1)
Input#1, sFirststring, sSecondstring
If Mid(sFirststring, 1, 1) = "Hello" Then
If Mid(sSecondstring, 1, 1) = "Money" Then
forward this to youare@somewhere.com
End IF
End If
Loop

Thanks,
Bil

How To Read Text File Line By Line ?
I want to read Text File line by line until EOF. How can I do it?

Read A Text File Line-By-Line
I have a text file, and I want to read each line at a time.

Read Text File Line-By-Line
I need to take a text file, read it line by line, and put certain lines into an array...

I need some help on the reading line by line part...

Can anyone steer me in the right direction? I don't need to read it all into an array, just 1 line at a time, and if the line meets certain criteria, put THAT LINE in an array...(I can handle the "if it meets certain criteria" part...)

Thanks!!

Read Text File Line By Line Through VB
Dear

I want to Read Text file through Vb.

How To Write The Content Of A Textbox Into A Record Of An Excel File?
hello there,

Suppose you have a text box.

1. you want the content of the text box to be written into an Exel file by clicking, say a command button.

2. you want the data coming to your serial com to be written directly into an excel file.


How would you do that. I would appreciate your help.

VB6Fan

DETECT AND RECORD SOUND TO WAV FILE FROM LINE IN
My question is If i can record audio from line in via visual basic andmci control.
Is anybody know how can i make the recording to start automatically whena sound is detected and stop recording after a period of silence.

Thanks!

Reading The Content Of A Text File Via Line Input, Backwards!
I am using Line input to read the content of a txt file into a listbox. As each line is read in, a function is called upon to check for something. It would be very helpful if I could read the text file in reverse, so the first line is read last.

Is there a way to do this?

Thanks!

Move A Line From One Text File To Other
--Boundary_(ID_IcqQ20ltU2cXv+X9vXwrZg)
Content-type: text/plain; charset=iso-8859-1
Content-transfer-encoding: 7BIT

Hi

I am displaying one line Example Name from one text file name tip.text
in a Lable at my form.
i want that once that line from text file tip.text display then under
one command butten i can move that line from tip.txt to other file
tipfinal.text
Thanks

--Boundary_(ID_IcqQ20ltU2cXv+X9vXwrZg)
Content-type: text/html; charset=iso-8859-1
Content-transfer-encoding: 7BIT

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1170" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>I am displaying one line Example Name from one text
file name tip.text<BR>in a Lable at my form.<BR>i want that once that line from
text file tip.text display then under<BR>one command butten i can move that line
from tip.txt to other
file<BR>tipfinal.text<BR>Thanks<BR></FONT></DIV></B ODY></HTML>

--Boundary_(ID_IcqQ20ltU2cXv+X9vXwrZg)--

How To Goto End Of The Line Or Record Line
I created a download text file with the format of a header line and details lines. The system download allow only this type file format structure:

Line 1 Header line
Line 2 Detail line
Line 3 detail line
Line4 detail line
Etc

Each line represents a record. This data is required to be transfer to another system but the information must be transfer as one line string ie, Line 1Header lineLine2detail linesLine3detail line, etc

How can I delete the end of the line for each records, so the next line can start right after the previous line?

Thanks for your help

Line Input #1, Line...how Do I Read Ahead One Line (or Back Up One Line)
I am loading a file line by line using the LIne Input but at one point i need to look ahead at the next line to decided what to do on the current line...how do i look ahead one line? or how do i use the line Input function and then back up? Any help would be greatly appreciated.

Shane Thomas
p.s. please email replys in addition to the reply of post too
shathoma@nmsu.edu

How Can I Read One Line By One Line From A Multiline Text Field ?
i have a few rows of data on the text box

is there anyway to do this ?

Read A Word In A Line Of Text And Delete That Line
I have some aim logs that I'm going to put in .txt format, and I want to be able to delete the text that the other person has written.

Is there a way for me to specify a screen name and have the program delete that line of text?

Thanks,
Brad

Set The Position To Read The Record In A Text File
how will i set the position to read the record in a text file... ex. i have a text file with 500 records, if i have a variable iposition and iqty,
iposition = 250
iqty = 100

the program should start reading the record number 250 until 350 (bcause of iqty = 100) then store each record in a table...

i really need ur help, im so new in using vb 6 thanks a lot

Read File Line By Line, Populate Listbox
How can I read a text file line by line, and for each line, make a new row in the listbox?

Run Time Error When Read File Line By Line
I'm trying to read a txt file line by line that I can stop reading at any place I want.
Below is the code:

VB Code:
Do While Not EOF(1)  Line Input #1, fString     Text1.Text = Text1.Text + fString + vbCrLfLoop

The problem is, if the txt file has empty lines at the end of it, it will have run time error : "Input past end of file".
Does anyone know how to solve this problem?
Thanks in advance!

Faster To Read Line By Line, Or Whole File And Then Process?
Which is faster: Opening a file line by line... or creating a dynamic arr() and get the whole file, split at new line, and put it into the array, then use the array?

[Help] Read Last Line Of A Text File
Hey Guys,

Im in the process of trying to make an application and have come to a stand still, unable to find out how to read _just_ the last line of a text file.

The problem is that, instead of loading XXX.txt which could contain 2000+ lines, then getting the last line, causing major overhead, I am trying to find a method for getting just the last line.

Thanks in advance,

Regards,
Mark

Read A Text File Line
Is there any way to make a VB program read a certain line from a text file?

If you have a computer or Windows 98 question, ask me.

Read Text Per Line From File
Well, my file is named "config.usof" (its just a text file). I've got one value per line and I'd like to dim a value for each line... any help? Thanks guys... ur savin my project

Read Last Line Of Text File
Hi Guys,

I needed some help regarding file reading in VB 6. I am writing a program that needs to insert a record in a text file. The text file has following format..

Date, Time, Open Price, Close price

Now i need to insert record only if date is greater than last date in file.

So everytime I need to insert record, I have to open file and read sequentially and then I reach last record. This takes time.

IS there a way to read such file in binary or whatever so that i can get last record straight away or very quickly without going thru all records one by one.

If there is can anyone post a small code.

[Records in the (text) file is like -

01/01/2006, 1100, 123.33, 155.55
01/01/2006, 1130, 122.22, 134.33
01/01/2006, 1200, 112.22, 124.33
so on ... ]


Thanks a lot,

Cheers,
GR

How Can I Go To Some Line In Text File For Read It?
If I have some text file that contain many line. And I want to go to some line for read it that line. How can I coding this case in VB?
I know that I can use "For" loop to go to that line but I think VB may be has some better way to go to that line directly

How To Read Certain Line In Text File
Is there a way to read certain line of text within a text file?

What I have is a text file that is sorted A-Z. And let just say
when the user clicks on words begin with 'b', I want to go
to a know lines within my text file. My text file is not fixed lenght!

Let just say a = 1, b = 50, c = 100 etc... So how can I read
line 50 when user clicks the b word?

Thanks in advance for the help.

Read First Line Of Text File
Is it possible to just read in the first line of a text file? I really don't want to load the whole thing into memory just the first line.

Thanks.

How Read Each Line In A Text File ?
Hello everybody

I want my VB 5 Project to read a text file line by line to put each line in an array.


Thank you very much if you can help me.

Read (eg: Line No 10) From A Text File
Hello ,

I have this text file , if i find a particular string in a line then i want to delete the line.I can find the string position with the instr function, i want to start reading from that line onwards instead of having to go through the entire file to come across that line

any ideas how do i ??

thank you for your help

How To Read Last Line In A Text File?
Hi all,

I want to read last line in a text file but don't want to browse through all other lines before approach the last line. How can I do it?

Thank you!

Resolved:move Pointer To Next Subsequent Line In Text File Same As Recordset.movenext
Hi All, Pls Pls kindly help me.

How to move pointer to next line in reading text file by while loop similar to rs.movenext (dim rs as adodb.recordset)

Dim F As Long
Dim SLine As String
Open filepath & ".SNWSN1.TXT" For Input As F

>While Not EOF(F)
>Line Input #F, SLine
' want to insert some condition in which
'if criteria matched ==> jump to next line and then read.
'no return needed
>Wend

Close #F

Thanks a lot.

How To Read 1st Variable Line By Line From A .txt File
1st question. Is it easier if I use a database I assume?

Say for example I have a file named test.txt which looks like this

"Test1"
"Tst2"
"tt3"

And I do a search for "Tst2" how would I go through file to find that?

Open test.txt for input #1
white not EOF(1)

????

I am totally lost here. And are there any thorough tutorials online for visual basic 6 or a GOOD quality book that would touch on things like this an DBGrid's? The only one I have is too basic.

Thanks in advance and I apologize for the question but I can't find a resolution anywhere.

Open File And Read Line By Line
how would i open a file and read line by line?
i have it opening and reading this way

FNum = FreeFile()
Open fileIn For Binary Access Read As #FNum
FBuf = Space$(LOF(FNum))
Get #FNum, , FBuf
correction = FBuf
Close #FNum


but i want to be able to read each sentence at a time and for there to be a loop for the whole text file that goes through sentence by sentence

the file looks like this

<blah blah blah>
<blah blah blah>
...


basically i want to read each <blah blah blah> at a time

Any ideas??

Read A Random Line From A Text File
i need to open a random line of a text file and save it in a string varibale. how would i go about doing this?

thnx for any help
Matt

Read From A Text File One Line At A Time
hello i've written this function bellow to read information from a text file.


Code:
Private Sub cmdLoadConfig_Click()
Dim strTextLine As String

Open "C:abcd.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, strTextLine
txtRangeSelect.Text = strTextLine
Loop
Close #1
End Sub


i was just wondering how to read one line at a time. so i can make a variable equal to a certain line.

eg

variable1 = line 1 of the text file
variable2 = line 2 of the text file

any ideas?

thanks a lot

Read Text File Until Blank Line
Hello, I am trying to read a text file into a string until a blank line is reached. For example,

textfile.txt
this is the first line
I want these lines read

I do not want these lines read
or this one

EOF

I have tried using Line Input with If line = "" exit do, however, it seems only to load one line, if any....
So how is a blank line in a file detected?
Thanks so much

Greg

Read Random Line From Text-file
Hi!

I want to read a random line from a text file. My text file has 315 lines in it. Here is what I have written so far:


Code:
Dim number As Integer
Dim line As Integer

number = Int(300 * Rnd) + 1
Open App.Path & "words.txt" For Input As #1
For line = 1 To number
Input #1, line
Next
MsgBox (line)
Close #1

But every time I try to run this, the debugger informs me about Run-time error '62': Input past end of file.

The problem can't be with the randomizer because I checked the output once and it said that the number was 8. And since my text-file is 315 lines long, I really can't figure what is the problem.

Can anyone help me?

Read/delete Line From Text File
Hi
I use VB to read a line of code from a text file and store it in a variable - no problem

what I would like to be able to do is

read the first line from a text file store in a variable
then delete that line from the text file
then repeat the process for as many times as I like

So I go to the first line read it store it delete it – read it store it delete it etc etc

Any ideas how this could be done?

Thanks

Read From A Text File One Line At A Time
Sorry to revive an old thread but its probably better then adding a new one

Im using a code to download a file and then read from that file, the file downloads OK, all the text in the downloaded file is correct but this code doesnt seem to be working


Code:
intFile = FreeFile()
Open CurDir & "
otice2331.dat" For Input As #intFile
Line Input #intFile, strLinenews1
Line Input #intFile, strLinenews2
Line Input #intFile, strLinenews3
Close #intFile
it works if i use just the Line Input #intFile, strLinenews1, if i put the other 2 i get a Input past end of file, but im sure the file has more then 3 lines.

Any idea whats wrong?

Read A Specific Line From Big Text File
How can I read specific line from big *.TXT file?
For example *.TXT file size is 200MB and I want read specific line from this file how can I do that ?

Read From Specific Line In Text File
How can I read and write to a specific line in a textfile.

Say I want to write a string to say line 5 into info.txt and later I want read line 5 from info.txt

thanks Vidar

Read Only Last Line Of Text/ascii File
Hi Guys,

I needed some help regarding file reading in VB 6. I am writing a program that needs to insert a record in a text file. The text file has following format..

Date, Time, Open Price, Close price

Now i need to insert record only if date is greater than last date in file.

So everytime I need to insert record, I have to open file and read sequentially and then I reach last record. This takes time.

IS there a way to read such file in binary or whatever so that i can get last record straight away or very quickly without going thru all records one by one.

If there is can anyone post a small code.

[Records in the (text) file is like -

01/01/2006, 1100, 123.33, 155.55
01/01/2006, 1130, 122.22, 134.33
01/01/2006, 1200, 112.22, 124.33
so on ... ]


Thanks a lot,

Cheers,
GR

Function To Read A Random Line From A Text File
has anyone got a function i can use for returning a random line from a text file? i have a quotes file and i want to make it print any line from the file which has over 2000 quotes!!

How To Read The Last Line Of A Text File Without Looping From The Begining
I like to check the last line of the text file before adding new data to the text file. This is required to avoid duplicate data.

Is there any way to read the last line without looping through the whole text file? Or, is it possible to loop from the last line of the text to the first line i.e. reverse direction?

Appreciate, your help.

Thanks.
Thiru

Read A Random Line From A Text File Separated By A %
How can i load a random line from a text file wich is separated by a %?
for example i have this text:

%
And 1.1.81 is officially BugFree(tm), so if you receive any bug-reports
on it, you know they are just evil lies."
(By Linus Torvalds, Linus.Torvalds@cs.helsinki.fi)
%
"...and scantily clad females, of course. Who cares if it's below zero
outside"
(By Linus Torvalds)
%

So the program will read a random line wich is between the %

Thanks in advance

Text File With 10 Lines, Want To Read And Display Only Second Line ... How?
Newbie question: I have a textfile (mytext.txt) containing 10 lines total: I have successfully coded how to read and display the first line OR all lines from the text file ... Next Step: How/What would I code to read and print say, only the second line?

Here's what I have:

Quote:





Option Explicit

Dim sampleoutput As String


Private Sub Command1_Click()
'Reads and displays first line from text file.
Open "C:My DocumentsPOS405dbtxtsamplemytext.txt" For Input As #1
Input #1, sampleoutput
Picture1.Print ""
Picture1.Print sampleoutput
Close #1
End Sub


Private Sub Command2_Click()
'Runs a loop to read and display all lines from text file.
Open "C:My DocumentsPOS405dbtxtsamplemytext.txt" For Input As #1
Do While Not EOF(1)
Input #1, sampleoutput
Picture1.Print sampleoutput
Loop
Close #1
End Sub


Private Sub Command3_Click()
'This code needs modification to read and display second line from text file.
Open "C:My DocumentsPOS405dbtxtsamplemytext.txt" For Input As #1
Input #1, sampleoutput
Picture1.Print ""
Picture1.Print sampleoutput
Close #1
End Sub





Thank you for any help.
~ Juanita

How To Read Multiple Line Text File Into A Variable
Hi,

I just found this site tonight. I've just started learning to program with Visual Basic and I'm having a very frustrating problem that I'm hoping someone here can help me with.

This post is a bit long. Sorry about that!

This has probably been asked many times before. My question is, how can you open a multiline text file and input EVERYTHING in the text file to a string variable? Basically, the text file will just be a list and the program will have to determine what items are on that list. I know how to open and save text files, and display text files in a textbox, but for some reason I can't figure out how to input an entire text file into a variable. It will only read the first line, and seems to ignore anything below the first line. I've been hunting on Google all night to try to find out about this, but with no luck.

Here's an example similar to what I need to do:

Let's say I have a text file named "List.txt" I have a command button that will add an item that the user chooses to this list.

Now let's say that the item the user chooses could be the string variable "new_item"

So I would have a command button with this code:

new_item=InputBox("What would you like to add to the list?")

Open "List.txt" For Append As #1
Print #1, new_item
Close #1

If we put in "a new car" for example in the input box, then this would be entered into the text file "List.txt."

Then let's click the command button again and put in "a boat" into the input box. It should then append the text file to read:

a new car
a boat

So far, so good. Now, let's say I have another string variable, named items_on_list. I also have another command button that will open the text file and determine what is on the list, with predetermined results if certain things are on the list. For example:

Open "List.txt" For Input As #1
items_on_list = Input(LOF(1), 1)
Close #1

What I WANT to do is this (again, just a generic example):

If items_on_list = "a new car" Then MsgBox("A new car, eh? Better save up!")

If items_on_list = "a new car a boat" Then MsgBox("Wow! A new car and a boat!")

But the problem I'm having is that the program would only read the first line and would ignore anything else. How can I open a text file and assign EVERYTHING, a multiline list in other words, to a string variable?

What I'm actually doing is working on a sort of strategy game that simulates a railway company. I know there are already dozens of games like this, such as Railroad Tycoon, etc. but this one will simulate a small railway company that was once in my area. I have a variable that I would like to use to keep track of specifically what locations the user has built lines to. Each time the user builds a new rail line, it would have to be appended to a list. There are certain instances, such as when a map is displayed showing all the rail lines, when this list would have to be opened and read into a variable, to determine which map to display in a picture box.

Again, I'm sorry for this post being so long! As you can tell, I'm still very new to all this. But this has been a very frustrating problem. I hope someone can help. Thank you!

Chris T.
San Bernardino, California

Copyright © 2005-08 www.BigResource.com, All rights reserved