Read Lines In Files... E.G Line 8 PLEASE Help Me
Hi, Please could someone give me the code to make it so that my project open a file to read from and read a lien number of my choice...
The code would probaly be in a midule then i would insert the code into a command button
e.g:
Code:LineNum(8)
This will read from "C: est.txt" and on line 8
If u dont uderstand plz say so...If u do plz help
Thx
------------------------------------------------------------------------------ And when a man gets to heaven, To saint Paul he'll tell: 1 more soldier reporting sir, I served My Time in Hell 6 June 1944
2GB DDR400 RAM, 3.4Ghz EM64T P4 Socket 775, 200gb PATA HD 8mb cache, 500GB WD 16mb Cache (Master), 256mb 9950 ATI RADEON AGP ,19" LCD, and a 250W PSU
Running Vs6 Enterprise, running all vs8 products express edition
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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
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
Hmm - New Lines Arent Read As New Lines By Vb In A File
Heres the situation
im using urldownloadtofile to download a text file from the internet onto the harddrive. although the textfile on the net has 5 items, each on a single line, when i use that function the file saves as 5 items all on a single line.. and where a new line is supposed to be, i see a "box" in notepad..
needless to say, when i try to load the file into an array using Line Input, all 5 items are on a single array number, instead of one item in each array number..
heres what i mean..
text file online:
a
b
c
d
e
text file when downloaded to hd:
a[]b[]c[]d[]e
the box is interesting, if i copy the entire text from the file on my hd and paste it, they paste with all 5 items on seperate lines..
my question is, how can i load a[]b[]c[]d[]e with one item in each array with VB? line input wont work cause itll store a[]b[]c[]d[]e in one string
Read Lines And Count Lines From Txt File - Thank Ye All
hello again
im back for some more help, so i hope you guys can.
ive had a quick search on the forums for this but cant find anything that helps, so heres my problem:
i have this code:
Code:
Function random2()
Dim lines As Integer
Dim current As String
lines = 0
Open "C:files.txt" For Append As #1
Do While Not EOF(1)
Line Input #1, current
lines = lines + 1
MsgBox (current)
Loop
Close #1
txtFILE = lines
End Function
but that code doesnt work, it does count the lines at all, i get no msgbox's, no count, no nothing.
any help would be much appreciated.
thanks.
Primary_Slave
----------------------------------------------------------------------------------------
I'm all wrapped up in my binary blanket and I'm coding on late into the night
----------------------------------------------------------------------------------------
Edited by - Primary_Slave on 11/4/2004 9:46:42 AM
Reading File Line By Line With Comma's In Lines
how is this does? I need to read line by line where each line has aprox about 30+ comma's.
currently tried using
Code:
Open App.Path & "monster.txt" For Input As #1
While Not EOF(1)
Input #1, line
dbObj.Execute (line)
Wend
Close #1
Loading Lines From A Text File Line By Line
I need to be able to load a line from a text file, perform actions on the line then read out the next line and perform the same actions each time adding the text to a text box, so that by the end the text box will contain all the information from the text file but formatted as to how my code formats it.
My Knowledge of VB is quite limited so explanations of how to use any code posted will probably be needed.
Thanks in advance
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@
Reading Certain Lines Of Files And Outputting Those Lines
This is what I am trying to do and I think I am going about it all wrong.
I am trying to read a log file (ascii) and only want to read in certain pieces of information (e.g. a failed request for a web page) and then I want that information written to a new file.
I wont even attempt to post thw code I have trying to work with, if someone can give me some pointers of post some example, I would really appreciate it.
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??
What's Best Way To Do Read These Lines?
Each day I am going to first create a text file manually like this:
apples 100
oranges 50
peaches 70
...
There will be about 20 lines. I want to read the items into a string variable and the numbers into a long variable. Each variable will be passed to its own procedure.
What is the best way to do this? Just use regular sequential I/O or do I need random access file? Or should I read each line into an array first and then split them? I don't care if I have to use commas or tabs instead of spaces. For example, it's fine if I have to make the text file look like this:
apples, 100
...
or
apples [tab] 100
...
Thanks.
Read Lines
what i am trying to do is open a file, and on each line will be some text, and for the text on each line, it will go on a row in a ListView. the thing is, i dont know how to find each line in a file or anything like that. I have found no information on this and am hoping someone knows how to do this, thanks
Lines To Line
Heh there's probably a simple solution to this...
Okay. Is there anyway I get multiple lines of text into one line?
Like this:
<Style>
This
Is
The
Content
</Style>
To This
<Style>This Is The Content</Style>
Mid Line Of Several Lines
I need to put the pointer of a rich text box in the end of middle line of several lines.
Eg
xxxxxx
YYYYYY#
ZZZZZ
AS these 3 lines is highlighted and a button is pressed. the pointer will be in position of "#" .
Many Thanks for you help!!
Can I Read Specified Lines In A Txt File??
Hi, i am a very new newbie.
I have a log file like this format:
0
...........(data in the log file, only one line)
0
...........(data in the log file, only one line)
0
...........
...........(data in the log file, two lines)
0
.........
.........
0
..........
0
I want read the data lines enclosed by the "0"s one by one and return it into string.
Any good idea?
Thanks....
Sami
Read Txt File Lines!!!
HI!!
Can anyone please tell me how can i read a specific line in textfile??
like i have 3 lines in text file:
this s first line
second line!
and the third!
How can i read second line???
Thanx!!
Read Lines From Textfile
I'll give ya a senario...
on my form, i have:
~10 command buttons
~1 text box
~1 Textfile,,, if this needs to be a .txt or .ANYTHING ill change in a sec (app.path + "settings.ini")
what i want it to do is when i push Command# i want it to display THAT # life of text into the textbox... so for example
if I push Command1 then
take line one from (app.path + "settings.ini")
and display it in Text1.text
if i push button 2, then i want it to display line 2,,, and so fourth, ive been stuck on this for a few days.. looked at multiple good websites, downloaded tutorials, tried to get help from online chats... no luck
please help me, im not really sure where to start, so im totally in the dark
How Do I Read Lines In A Textbox
How do i read lines in a textbox,
I use the open and open a file into the textbox
Text1, when i use :
Text1.Selstart = 0
Text1.SelLength = 200 it copies the whole line plus next line
line number 2, how can i just read the line i need
say i need line 20 this time i need to read the line, i would need the code that can do this job incase i am anotehr window, i had to leave the Text1.SetFocus out, also i had
to leave the SendKeys "{+END}", True because i maybe
in another window to avoid jumping to my program to get a line in a textbox Which is text1 how can i read any line in text1 text1 has 200 lines so i hope you can help me out with
a code that can get the line of text i need to get Line number
55 in a textbox how i go's about doing that.
Thank You Have nice Sunday Evening all
Bye
How To Read Certain Lines In A File And Tell What Is Different
Hello,
I have 2 files that I am going to compare. I was wondering how would I go about to read those files, and tell what is different. Take for instance...that file1.txt has <name>Fred</Fred>
<name>Barney</name>
<name>This</name>
File2.txt has...
<name> Barn</name>
<name> Fred</name>
<name> This</name>
Then I would have file box say file2.txt is different than file1.txt.
Because it has more names than than file1.txt and also file2.txt is missing barney.
Can someone tell me of a website that can help me with this, or can they help me themselves?
Read/Write 2 Lines
Hello all, i'd like to know howto read one line (define it to a variable), and then do the next with the string on the next line. thanks guys ^^
Read More Lines From Textfil
I'm making a program, were i can store my results from school. The results i put into a textfile called: variable.txt.
Now the program have tot read te textfile, and store each line in an variable.
So each line have is own variable.
But now the problem, i created this code for reading and store the variable:
VB Code:
strFile = "C:Documents and SettingsNilsBureaubladcijfersvariable.txt" 'your file with full path file must exist before you read from it Open strFile For Input As 1 'open text file for reading Line Input #1, strTemp 'read first string to variable Close #1 ec1.Text = strTemp
As you see it opens the file variable.txt, read it and puts the data on line 1 into the variable strTemp. After that the variable is shown in an textbox called ec1.
This works fine, but i have more results, and another result is on the second line in variable.txt. I wanna do the same thing with the secondline as with the first line. Someone knows how i should do this?
Read Multiple Lines
Hi,
If I have a textfile with, for an example, 3 different lines, how can I read that lines and put them in 3 different textboxes per line.
thnx
VB.Net Read Multiple Lines In Txt
Hey Guys,
Does anyone have a code on how to read a txt file with multiple lines?
Example of text file
this is my first line
this is the second line
this is the third line
this is the forth line
here is my code but it only displays the last line.
Code:
Imports System
Imports System.IO
Public Class Form1
Private Const FILE_NAME As String = "C: est ext.txt"
Public Sub Main()
If Not File.Exists(FILE_NAME) Then
TextBox1.text = "{0} does not exist." & FILE_NAME
Return
End If
Dim sr As StreamReader = File.OpenText(FILE_NAME)
Dim input As String
input = sr.ReadLine()
While Not input Is Nothing
TextBox1.Text = input
input = sr.ReadLine()
End While
sr.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Main()
End Sub
End Class
Read Certain Lines From Txt File
I am reading a txt file for a puzzle game. I use the first line for the Category. The rest of the lines are the answers. I can read line 1 fine to get the Category. I can also read All the Lines for the answers. I need to know how to only read from Line 2 to the EOF for the answers.
Thanks in advance,
Phil
How Do I Keep Only The 1st Line In A String Of Several Lines With The Same Name?
Hello there !!!
Say I have this string:
Code:
line1
line2
line*
line*
line3
line5
line77
line*
I think you get the idea
anyways, from the several lines with the same name(line*)
I want to keep only the 1st one of those... meaning, I'll have this in the end:
Code:
line1
line3
line*
line8
line5
line77
BTW - deleting always the 4th&8th lines(those with the same name, but not the 1st ones) won't work cause I don't always know what the user will import and in what order the lines would be.
thx in advance.
How To Put 2 Lines Of Code On 1 Line?
Simple, just can't find it.
ie:
pt1.X=100
pt1.Y = 200
pt2.X=120
pt2.Y = 300
I'd rather say:
pt1.X=100 .. pt1.Y = 200
pt2.X=120 .. pt2.Y = 300
help?
How To Break This Line In 5 Lines
Hello
I want to write the follwoing SQL Statement in break line for each field.
Code:
Db.Execute "INSERT INTO TranDetail (Mid, EId, AcId, ProdId, AmountDr, AmountCr, Descrip) VALUES (" & LblTId.Caption & ", " & Val(RsLov(0)) & " , " & Val(TxtId) & " , 0, " & Val(TxtDebit) & ", " & Val(TxtCredit) & " , '" & "Opening Balance" & "')"
I want to write this as below
Db.Execute "
Insert Into
TranDetail
(Mid,
Eid,
...
...
..
Please help me
Read From File And Store Lines
Hi there,
This is the code I have so far:
I wish to open this text file and then store each line of the text file in a different variable. Each line consists of a file path.
This is my code so far
It would be really good if anyone could help. Thanks.
Code:
Public Sub actuallybindnow()
Dim thefilenames As String
Open App.Path & "indhelp.txt" For Input As #66
While Not EOF(66)
Input #66, thefilenames
Wend
Close #66
End Sub
How To Read Different Lines Of A Text File?
I'm sure this is an easy enough question to answer but I wasn't able to find any threads about it so my apolgies if it has already been answered.
Basically what I need to do is read different lines of a text file depending on a random number for example on a number of 4 it will read line 4 of the text file. I am aware how to read the first line of a text file with
Open ("C: est.txt") For Input As 1
Line Input #1, strTest
Text1.Text = strTest
Close #1
however I am unaware on how to read any other lines.
Any help is greatly apprecitated thanks in advance
Read First Ten Lines Of A Text File?
I have some code that currently reads the first line of a text file. I want to change this and have it read the first ten lines, is this possible?
Here is the current code (blatantly simple):
'Open File for Reading
Open workfile For Input As #1
'Read in first line of file
Line Input #1, strFilesText
Close #1
Thanks.
|