Newbie Question: Read Line By Line?
how would you read line by line in a text file? stupid question...tried lookin at the tutorials section;
thx!
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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
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
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
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
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!
Read Line By Line Problem & Question
have a text file that I need to read line by line. This text file is very large (upwards of 1.5GB). The problem with this is that the lines are not separated by normal vbCRLFs but by Unix line feeds which means I can't use the normal Open Blah as #1.
I have tried reading the file in and changing the vbLF to vbCRLF which works for small files and even putting the thing into an array and splitting on the vbLF, but it just won't work. The file is so large that I can't just read the whole thing into memory because it will kill the system.
I know other people may have experienced this because this is an Apache web log and I am hoping someone has some insight or knows of another way or even a custom ReadLine Function that is out there that someone else has built to solve this.
Thanks in advance.
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
Read Line By Line Problem & Question
I have a text file that I need to read line by line. This text file is very large (upwards of 1.5GB). The problem with this is that the lines are not separated by normal vbCRLFs but by Unix line feeds which means I can't use the normal Open Blah as #1.
I have tried reading the file in and changing the vbLF to vbCRLF which works for small files and even putting the thing into an array and splitting on the vbLF, but it just won't work. The file is so large that I can't just read the whole thing into memory because it will kill the system.
I know other people may have experienced this because this is an Apache web log and I am hoping someone has some insight or knows of another way or even a custom ReadLine Function that is out there that someone else has built to solve this.
Thanks in advance.
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!!
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 File Line By Line
Hi,
I am making a program to read from a file and write to another. I have done following:
--------------------------------------------
Dim strRead As String
Open "abc.txt" For Input As #1
Open "abcen.enc" For Output As #2
Do While NOT EOF(1)
Input #1, strRead
Write #2, strRead
Loop
Close #2
Close #1
---------------------------------------------
But, it read only the first line of the source file and writes it too. How will it come to next line till the EOF.
Read String Line By Line
if the original string is
aaaa
bbbb
cccc
dddd
eeee
ffffff
if i want to convert it as
a(1) = aaaa
a(2) = bbbb
a(3) =cccc
a(4) = dddd
sorry for a naive question !
Read TXT Line By Line From Website
I know how to read line by line from a txt file on my computer, but what about reading line by line of a txt file on a website? (www.website.com/example.txt)
How To Read Text And Use It Line By Line
Hallo everyone,
I need help if its not so hard.
I am in a challenge site and one mission is to make a brute forcer
for a page like this www.site.com/../../../password=
I need a part of this project
So...
1) how can i make a button to read a .txt file and pass it into a listbox or anything else (excel or sth i dont know) in the form?
And after that
2) how can i make the program read the listbox line by line?
Thanks in advance for your time.
Greets
Read Txt File Line By Line
Have a txt file and i want to read line by line...
Only a prob. the dimension is 49 mb !!!!
EXistis a best way to read in very fast time?
HELP!
Read File Line By Line And...
I want the user to be able to write like http://www.google.com in one
textBox and Google in an other textBox.
Than I want the user to press a button when done. The text will then be past
like http://www.google.com,Google in to a file.
I want the user to be able to send as many links with names as they want to
that file. Then I want my program to be able to read from that file as I
start the program from a button at my form and use it in the program.
I am using MS Agent and I want the user to be able to write down links like
i described and then when I start the agent I want the agent to "build"
this:
All the names the user wrote:
Merlin.Commands.RemoveAll
Merlin.Commands.Add "Google", "Google", "Google"
Merlin.Commands.Add "Lunarstorm", "Lunarstorm", "Lunarstorm"
Merlin.Commands.Add "Back", "Back", "Back"
Merlin.Commands.Add "Forward", "Forward", "Forward"
Merlin.Commands.Add "Close", "Close", "Close"
The Names and the URL the user wrote down:
Select Case UserInput.Name
Case "Google"
URL= "http://www.google.se"
objInternet.Navigate Adress
Case "Lunarstorm"
URL= "http://www.lunarstorm.se"
objInternet.Navigate Adress
Case "Back"
objInternet.Back
Case "Forward"
objInternet.Forward
Case "Close"
objInternet.Quit
End Select
I want to do something like this:
Read the file line by line split the line at the "," and pot the left and
right string in an array and then go to the next line and add that to the
array as well and so on.
Then I want to use it in the MS Agent as this, to be able to use the links:
(As the Link names is the odd numbers I will just write out the odd
numbers.)
for (i=1, i<= aryLength(aryLink[i]), i=+2)
{
Merlin.Commands.Add "aryLinks[i]", "aryLinks[i]", "aryLinks[i]"
}
Merlin.Commands.Add "Back", "Back", "Back"
Merlin.Commands.Add "Forward", "Forward", "Forward"
Merlin.Commands.Add "Close", "Close", "Close"
Then here it is a little harder, the Case Is the odd numbers in the Array
and the URL is the even numbers.
Select Case UserInput.Name
Case "Google"
URL= "http://www.google.se"
objInternet.Navigate URL
Case "Lunarstorm"
URL= "http://www.lunarstorm.se"
objInternet.Navigate URL
These are not taken from the file:
Case "Back"
objInternet.Back
Case "Forward"
objInternet.Forward
Case "Close"
objInternet.Quit
End Select
As you can see is this not a language that exist... I don't know how to do
it in VB 6 It is not the same as using PHP with mySQL...
I'm a newbe to VB and some other languages as well...So it's all a bit
confusing...
Plz show me in the right direction to get this to work :-)
Read A File Line By Line
What I need to know is, if I had a text file with the following:
Code:
Apples
Bananas
Peaches
How would I get the program to read the first line, put it in a string variable, ead the second line, place it in another string variable, and do the same for the third. I know howto read files, but notline by line.
Thanks!
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
Replacing A Line Of Text With A Blank Line, Then Delete That Line
The code below works perfect, retrieving the string of text that the user selects from the listview. Then I do bla bla bla. What I want to do is convert this so that the the user selects a string from the listview which corresponse to a string in the file. then click remove. my problem is, how do i remove a line of text from a text file? if i open for reading i cant modify the contents, if i open for writing it erases the data. and i dont want to write the data into a string, parse out the string that i don't want then rewrite the file.... that could be....not so good...
---------------------------------------------------------------------------------
'the line that actually is in the file..
email=gmatteson@myemail.com
i want to remove this line...
---------------------------------------------------------------------------------
Dim strSelected As String
strSelected = lvwAccounts.ListItems(lvwAccounts.SelectedItem.Index)
Dim objFSO As New FileSystemObject
Dim objFile As File
Dim objTS As TextStream
Dim strReadline As String
Dim strFind As String
Dim strData As String
Dim strEmail As String
Dim blnFound As Boolean
Set objFile = objFSO.GetFile(App.Path & "pop3a.txt")
Set objTS = objFile.OpenAsTextStream(ForReading)
Do Until objTS.AtEndOfStream Or blnFound = True
'reads line in file
strReadline = objTS.ReadLine
strFind = "="
strData = (InStr(1, strReadline, strFind) + 1)
strEmail = Mid(strReadline, strData)
If strEmail = lvwAccounts.SelectedItem.Text Then
frmEdit.txtEmail = strEmail
blnFound = True
End If
Loop
---------------------------------------------------------------------------------
Thanks,
- Gabe
Read Line By Line Doc
hi,
i have word file having question of type multiple choices .i need to convert to mdb.how can i read line by line doc data.
thanks in advance
karuna
Newbie Help On Command Line Structure
Hi all,
Im a new user to VB and have a DB designed in Access XP, i have it containing simple VB code that i have managed to work out by my self. However i am starting to have trouble with some parts and was wondering if anyone could offer any sites that contain commands and there structure / use?
thanks for any
Tezz
PS im running the Visual basic that comes with Access XP
Newbie Command Line Question
I am using VB to go through a 800MB file looking for errors and would like to be able put a percentage complete out to the command (DOS) screen.
Is this possible? Any suggestions?
Thanks
Making A Line Break In A Text Box - NEWBIE QUESTION
Newbie question How can I make a line break in a text box when outputting lines of code? I have a looped routine adding information to a text box each time but when it is done, the info is all on one big long line. When it adds it, I'd like it to take a new line for the next time before I loop. Is this possible?
How To Read Line 29 From A .txt ?
Hi
I'm trying to figure out how I can read one single line (say for instance line number 29) in an .txt, without opening the entire document. (we are talking about a 10 mb .txt)
Any idea guys ?
- Preben
How To Read This Line?
Hi guys, i have a file witch has lines like this one -> 11/01/2006,00:46:39,23.745888.
I wrote this simple code in order to read the file and store the text fields to a database (i also display them to a second form in order to see what is going to be stored in the database).
Private Sub Command1_Click()
Dim date, time, longitude As String
Dim FilePath As String
FilePath = Text1.Text
Form2.Cls
Form2.Show
Close
Form2.Print "date", "time", "longitude"
Open FilePath For Input As #1
Do Until EOF(1)
Input #1, date, time, longitude
datgsm.Recordset.AddNew
Form2.Print date, time, longitude
Loop
Close
End Sub
For this line -> 11/01/2006,00:46:39,23.745888, i'm getting "11" to the first field, "0" to the second one and the correct one to the third field.
So, i suppose that i have to make something like parser using instr(), isDate() etc. I tried to write something like that but it didn't work. Any suggestions?
Thanks in advance!
Read Last Line Only
Im making a program wich checks if certain words are used. Im using this code now, but its not working the way i want it too.
Code:
If InStr(Text1.Text, "looking") Then
MsgBox "bla"
End If
the problem is, im using a timer that looks for the word "looking" but i want it to check for the last line only in the textbox. (the txtbox is on multiline)
Cause if i dont do this it keeps repeating the msgbox cause it see the "looking" all the time. So my question is how can i let it read the last line only in a txtbox.
Thanks for any help.
Read Line
I have 6 lines in a file. I want to read lines start with "pgm."
How do i do it. I know that there is a way to do it
for i = 1 to 4
Line input
next
But i dont want to do that way, Can anyone shows me how do read line starts with "pgm."
Thanks
Read Line
ok need to no how to read a line in a text box? example.
if text1 = "yes" then
but yes is on the third line down.
Read By Line
i would like to know how to read line by line firt to read the first line then the next ....
tanks
Read Next Line?
how do i get my prject to read one line after the next like vb does?
Read The X Line
Hi there!!!
I asked about this before but I didn't get an useful answer. I want to read a certain line of a text. For example, if I got:
Dog
Cat
Canary
And I wanna get the second line, which is Cat... how can I do that???
The code I got with that answer opens a file, and I don't want it to open a file, I want to get the line of a text that is already loaded in the application... also, I don't wanna save it and then open it with that code, I just say it if someone gets that idea :-), lol.
So, what in fact I need, is to know how to get a certain line of a Text. Hope anyone can help me. If you do, thx very much!!! Cya!
Bye!!! Pol1
- trying to make the world graphically better -
Read The 'x' Line
Hi there again!!!
I have another question... ... How do I to read the line I want from a file?, for example:
Quote:Dog
Cat
Mouse
Cheese
How do I to read the 3rd line to check if it says Mouse?, that's my point. I hope you can understand me... can't you?, thanks, see you!
Read Line Above Last From File
Hello,
I need to read the line above the last from a file.
here is the text file i need to read from:
Chileno/Denver: de donde
Joe dirt: hi guys
scarecrow: hey
stanley2: where is the armor
x
How can i read "stanley2: where is the armor"
Read Specific Line
Can someone tell me how to read the line that start with "03" in a file?
Thks in advance
Not Able To Read The Next Line In The Notepad
problem : i want to read the next lien from a notepad which hgas a matrix for example
1 1 1
0 1 1
1 1 1
After the first loop i want the str2 to be 0 1 1 ?Ho can we do that .any pointer plz.....or if u see nay fault in my code.....reply back at your earliest convenience. thanks
Dim x, y, z As Integer
Dim fname As String, str3(10, 10) As Integer, str2 As String, col1 As Integer
fname = "C:sss1foxoutput.txt"
Open fname For Input As #3
y = 1
While Not EOF(3)
Line Input #3, str2
str2 = Replace(str2, " ", "")
For x = 1 To Len(str2)
str3(y, x) = CInt(Mid$(str2, x, 1))
Next x
y = y + 1
Wend
MsgBox str3(2, 1)
Read Last Line Only Of Txt 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 Do I Read From Just Last Line Of File? (txt)
On my program, a user is only allowed to do a certain amount of tasks per 24 hours. I have set the task number in the registry. When the program loads, it reads the text file and sees if 24 hours has passed (or if it was yesterday) and then it'll reset the registry.
The textfile looks like this:
Code:
"6966969","Sent Request on 1/6/2006 at 3:30:13 PM"
"26660046","Sent Request on 1/6/2006 at 3:30:19 PM"
"44955616","Sent Request on 1/7/2006 at 3:31:18 PM"
Here's how I'm doing it.
Code:
Private Sub Form_Load()
Dim strArray() As String
Dim intFNum As Integer
i = GetSetting("Project1", "dailycount", "count", i)
intFNum = FreeFile
Open App.Path & "log" & username & ".txt" For Input As #intFNum
strArray = Split(Input(LOF(intFNum), intFNum), vbCrLf)
Dim v, S As String, li As String, oi As String, m As String, time As String
For Each v In strArray
If Len(v) Then
li = Mid(v, 2, InStr(v, ",") - 3)
m = Mid(v, InStr(v, ",") + 2): m = Left(m, Len(m) - 1)
oi = Mid(m, InStr(m, "on") + 3): oi = Left(oi, InStr(oi, "at") - 2)
If Date > oi Then
SaveSetting "Project1", "dailycount", "count", 0
Close #intFNum
'Exit Sub
End If
End If
'End If
Next
Close #intFNum
End Sub
As you can see, once it reads the first line of the text ("6966969","Sent Request on 1/6/2006 at 3:30:13 PM"), the first date it sees is 1/6/2006, then date is less than todays date and it'll reset the registry. However, it should just read from the last line because it's only the last entered date that really matters.
Read Specific Line
Hi,
In my current project I need to load ever first and every fifth text line (from a txt file for example) to 2 textboxes
However the current code I use only allows me to but all the 10 lines to 10 texboxes and use it after that.
So as far as I know this code is only usable to load either every line to a seperate textbox, or to get the first line from a text file
My current code is:
Private Sub File1_Click()
Open File1.Path + "" + File1 For Input As #1
Line Input #1, a1
Line Input #1, b1
Line Input #1, c1
Line Input #1, d1
Line Input #1, e1
Text1.Text = a1
Text2.Text = b1
Text3.Text = c1
Text4.Text = d1
Text5.Text = e1
End Sub
Hope you can help
tnx in advance,
Maartuh03
|