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 Thomasp.s. please email replys in addition to the reply of post tooshathoma@nmsu.edu
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
.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
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@
Line Input #n,,<string> Stops When [null] Is In The Line
VB6. Using line input #n,,<string. to read a file. It is a txt file and the records are variable length and may contain CTRL characters. When I read a record that has a [null] in it, it takes that as a CRLF and terminates the read. I therefore get a short record and the next record read is the continuation of the first one. My reading tells me that CRLF is the terminator of a record not [null]. A stumper for me. And yes, I am sure there is no CRLF AFTER the null. I read the record character at a time and it is a null all by its lonesome.
Thanks
matt.
Question is: How can I read this record FULLY at one time. I then have to go through and change the null to a space, so it has to be in the record, otherwise everything would shift.
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.
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 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!
Line Input Question && Line Parse ?
'I would like to change and edit
line 237 of txt file which is "Studentsnameisjohn1234567890"
'465 lines in total
Dim line1 as string
Open C: ext.text For Input As #1
Do Until EOF(1)
Line Input #1, line1
If LCase(Left$(line1, 18)) = "studentsnameisjohn" Then
Text1.Text = Mid(line1, 15, 4) ' Text 1 now displays john
End If
Loop
Close #1
If I decide to edit and parse line1 outside the loop, how do I put line1 back in to #1 after editing ?
For example entering the name "mark" in to text2.text to replace john
mid(line1, 15, 4) = text2.text 'I enter mark in textbox 2
I then click on a command button I call "Apply" to change the name which is where I am stuck as this does not happen ?
End product should look like this for line 237 of txt file "Studentsnameismark1234567890"
I would like to make the name change and then save the text file.
Any help appreciated
Really new at this...
Thx
Append Line To String With Line Input
How do you append a line to a string that I am inputing text into.
Code:
Open "T:crap_email" & strfile For Input As ff 'get a handle on file
length = LOF(ff)
While Not EOF(ff)
Line Input #ff, strfiledata 'input file into a string
Wend
I know about reading the text file all at once with LOF but I am troubleshooting something, and I need to read it line by line.
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??
Line Input Not Reading A The Whole Line
I am using Line Input to read lines out of a file. On loop 1, the code is reading the first line and printing to another file correctly. On loop two, Line Input is not reading the second line. It doesn't print anything (visible) into the output file. This does not happens on every line. For instance, it takes 7 loops to copy 5 lines to the second file. I do not have access the code that writes the input file. I am thinking there is some kind of code at the end of some of these lines that interrupts Line Input from reading the to the end of line. I need to make sure I am accouting for the number of lines that are being read.
Attached is the first 7 lines of the input file
-Jeff C:DocumentsandSettingsCulliJP1DesktopARAV-CBKM203AR2stageAero2stageAeroInput.dat
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
Why Won't This Input Code Work? It Won't Read More Than 1 Line?
Hello..
I have this input code, and it won't read more than one line for some dumb reason. Can somebody please help? Thanks.
Code:
Open App.Path & "customcommands.dat" For Input As #2
Dim tLine As String
Do While Not EOF(2)
Input #2, tLine
'now we have to get, and interpret these results.
Dim WhereIsIt1 As Integer
Dim WhereIsIt2 As Integer
Dim WhereIsIt3 As Integer
Dim WhereIsIt4 As Integer
Dim WhereIsIt5 As Integer
Dim WhereIsIt6 As Integer
Dim WhereIsIt7 As Integer
Dim WhereIsIt8 As Integer
Dim WhereIsIt9 As Integer
Dim WhereIsIt10 As Integer
Dim WhereIsIt11 As Integer
Dim WhereIsIt12 As Integer
Dim WhereIsIt13 As Integer
Dim FilePath As String
Dim TheCommand As String
Dim Variation1 As String
Dim Variation2 As String
Dim Variation3 As String
Dim Variation4 As String
Dim SayThis As String
If tLine = "" Then
Exit Sub
End If
WhereIsIt1 = InStr(1, tLine, ",", vbBinaryCompare) - 1
FilePath = Left(tLine, WhereIsIt1)
'MsgBox FilePath
WhereIsIt2 = InStr(WhereIsIt1, tLine, ",", vbBinaryCompare) + 1
'MsgBox WhereIsIt2
WhereIsIt3 = InStr(WhereIsIt2, tLine, ",", vbBinaryCompare)
'MsgBox WhereIsIt3
TheCommand = Trim(Mid(tLine, WhereIsIt2, WhereIsIt3 - WhereIsIt2))
'MsgBox TheCommand
WhereIsIt4 = InStr(WhereIsIt3, tLine, ",", vbBinaryCompare) + 1
'MsgBox WhereIsIt4
WhereIsIt5 = InStr(WhereIsIt4, tLine, ",", vbBinaryCompare)
'MsgBox WhereIsIt5
Variation1 = Trim(Mid(tLine, WhereIsIt4, WhereIsIt5 - WhereIsIt4))
'MsgBox Variation1
WhereIsIt6 = InStr(WhereIsIt5, tLine, ",", vbBinaryCompare) + 1
'MsgBox WhereIsIt5
WhereIsIt7 = InStr(WhereIsIt6, tLine, ",", vbBinaryCompare)
'MsgBox WhereIsIt6
Variation2 = Trim(Mid(tLine, WhereIsIt6, WhereIsIt7 - WhereIsIt6))
'MsgBox Variation2
WhereIsIt8 = InStr(WhereIsIt7, tLine, ",", vbBinaryCompare) + 1
'MsgBox WhereIsIt8
WhereIsIt9 = InStr(WhereIsIt8, tLine, ",", vbBinaryCompare)
'MsgBox WhereIsIt9
Variation3 = Trim(Mid(tLine, WhereIsIt8, WhereIsIt9 - WhereIsIt8))
'MsgBox Variation3
WhereIsIt10 = InStr(WhereIsIt9, tLine, ",", vbBinaryCompare) + 1
'MsgBox WhereIsIt10
WhereIsIt11 = InStr(WhereIsIt10, tLine, ",", vbBinaryCompare)
'MsgBox WhereIsIt11
Variation4 = Trim(Mid(tLine, WhereIsIt10, WhereIsIt11 - WhereIsIt10))
'MsgBox Variation4
WhereIsIt12 = InStr(WhereIsIt11, tLine, ",", vbBinaryCompare) + 1
'MsgBox WhereIsIt12
WhereIsIt13 = InStr(WhereIsIt12, tLine, ",", vbBinaryCompare)
'MsgBox WhereIsIt13
SayThis = Trim(Mid(tLine, WhereIsIt12, WhereIsIt13 - WhereIsIt12))
'MsgBox SayThis
Variation1 = "computer " & Variation1
Variation2 = "computer " & Variation2
Variation3 = "computer " & Variation3
Variation4 = "computer " & Variation4
TheCommand = "computer " & TheCommand
If Variation1 <> "" And Variation2 <> "" And Variation3 <> "" And Variation4 <> "" Then
If Results = TheCommand Or Results = Variation1 Or Results = Variation2 Or Results = Variation3 Or Results = Variation4 Then
RCA.Voice.Speak SayThis
Shell (FilePath)
End If
Close #2
Exit Sub
End If
If Variation1 <> "" And Variation2 <> "" And Variation3 <> "" And Variation4 = "" Then
If Results = TheCommand Or Results = Variation1 Or Results = Variation2 Or Results = Variation3 Then
'do something
End If
Close #2
Exit Sub
End If
If Variation1 <> "" And Variation2 <> "" And Variation3 = "" And Variation4 = "" Then
If Results = TheCommand Or Results = Variation1 Or Results = Variation2 Then
'do something
End If
Close #2
Exit Sub
End If
If Variation1 <> "" And Variation2 = "" And Variation3 = "" And Variation4 = "" Then
If Results = TheCommand Or Results = Variation1 Then
'do something
End If
Close #2
Exit Sub
End If
If Variation1 = "" And Variation2 = "" And Variation3 = "" And Variation4 = "" Then
If Results = TheCommand Then
'do something
End If
Close #2
Exit Sub
End If
Loop
Close #2
and I know there is probably a more efficient way to do this, but I don't really want to do it any better way. Please just tell me why it won't read more than the first line... Thanks
-compuXP
www.vibewave.com
Needing Experienced Programmer For Help - Parsing && Changing Line By Line In Txt File
Hello,
I'm a senior in HS and needing some help parsing a text file.
I have this in the text file:
ProjectList(0) = ""
ProjectList(1) = "A015"
ProjectList(2) = "A049"
ProjectList(3) = "A052"
ProjectList(4) = "C033"
ProjectList(5) = "C035"
ProjectList(6) = "C036"
ProjectList(7) = "C039"
ProjectList(8) = "E001"
ProjectList(9) = "E017"
ProjectList(10) = "E018"
ProjectList(11) = "E025"
ProjectList(12) = "G076"
ProjectList(13) = "G079"
ProjectList(14) = "H007"
ProjectList(15) = "H012"
ProjectList(16) = "K253"
ProjectList(17) = "M002"
ProjectList(18) = "M036"
ProjectList(19) = "M042"
ProjectList(20) = "M043
Problem:
The problem is that if i add another entry, for example, ProjectList(16) = "K254" it has to be in sequential order/alphabetical order. Well, I need to be able to add a line, and then from there renumber the rest of the projectlist items, from that item down.. Because if you add one, say at ProjectList(2), it messes up the order.. No big deal you say...but the rest of the file goes to 138 records and everytime you have to renumber it by hand...I'd like to automate this..
I have tried using Split function in VB, filter, Replace function, but I can't seem to break apart each line, increment the number, and then do that the same for the rest of the file, all while being able to have this functionality work no matter where or what number in the sequence it is.... If anybody could guide me, I would be indebted... Thanks!!
I have attached a text file of it if anybody needs to see what I'm talking about...
Prevent Multi Line Textbox From Wrapping Incomplete Words To The Following Line
Hi.
I've created a textbox that will mimic a mainframe screen that has a dimension of 80 X 24.
The following textbox properties are set as follows:
Multiline = True
Word wrap = True
When a user enters text into this textbox the text will wrap after every 80 characters, just like it would when typing on a mainframe screen.
PROBLEM: I would like the textbox to wrap only complete words to the next line...just like this forum textbox that I am typing into right now does..
would anyone know the code to accomplish this?
Thanks in advance..
marc
MsgBox Showing All Multi-line Footnotes That Have Carriage Return At End Of Line
Can I tell Word via VBA to show me all the footnotes that erroneously
have a carriage return at the end of multi-line footnotes. ?
To be more specific there are still people who press enter at the end
of a written line instead of let Word do the line break
automatically.
The MsgBox should say for example:
Footnote 1: carriage return, page 7
Footnote 2: carriage return, page 9
etc.
Could please somebody give me a hint ? Thank you very much in
advance.
Regards,
Andreas
Leading Spaces Of Each Line Ina Multi-line DataReport Field Has Been Trimmed
I have a multi-line textbox that update a SQL table field. However, when printing the field in a datareport, all leading spaces of each lines has been trimmed, just like all lines left-aligned. Is there any settings I need to set, or this is a bug of datareport? I got this problem in VB6 SP4 & SP5.
I've checked that the spaces have been saved in the SQL rec.
Moreover, I found that I put a multi-line textbox to a datareport label gets the same result.
Thx for your help.
Reading A Tab Delimited Text File Line By Line Into An Array
I have a tab delimited file created by an outside source.
I am using the below code to read it's contents into an array.
Function openFile()
Dim FileNum As Integer
Dim TotalFile As String
FileNum = FreeFile
' Reads the entire file into memory all at once
Open "c:DBUpdaterpgstd.txt" For Binary As #FileNum
TotalFile = Space(LOF(FileNum))
Get #FileNum, , TotalFile
Close #FileNum
TotalFile = Replace(TotalFile, vbNewLine, vbTab)
Fields = Split(TotalFile, vbTab)
'For X = 1 To UBound(Fields) Step 1
' Now the array can be used in the mdb comparing
'Debug.Print Fields(X)
'Next
End Function
My issue is that I am trying to read the array in lots of 15 as the text file has 15 columns of data.
Some of the lines only have 4 columns of data, this is throwing out my retrieval process.
Here is a sample of the text file. (copy and paste into a text file read it correctly)
seq_idlevel_idproduct_iddescription_line1description_line2description_line3description_line4supplier_idupc_apndiscount_percentbuy_price_exbuy_price_incrrp_exrrp_incGST_percent
10P1Computer Systems
20P2Workstations
30V1HEWLETT-PACKARD
40ZCOB9939XW6200 DUAL 3.2GHZ, 1GB, 40GB SATANO INTEGRATED GRAPHICSPO_3371793900.004290.0010.0
50ZCOD2329T5710 800MHZ 256/256 XPE THIN CLNTMicrosoft Windows XP Embedded; MS IE 6.0Transmeta Crusoe 800 MHz ; PC540A13.12671.38738.52772.73850.0010.0
6
Line two only has 5 tabs then the next line starts, this obviously throws out my reading of fields.
However this file can be imported into Access and all columns are correct, so I know it can be done, just not with my limited VB knowledge.
please Help,
David
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
Get Line Form Text File 1 Line At A Time
I am trying get some code that will get one line of txt from a file then after it done with that line grab the next line so on and so forth. I have been able to get it to run through a file but I can’t get to do it one at a time. Here is some of the code I am trying to using now.
Sub TextStream ()
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, _
TristateFalse = 0
Dim fs, f, ts, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(Form1.Dialog.FileName)
Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)
Call count1 ' Mycounter1
If Mycounter1 = Mycounter2 Then
ts.SkipLine
ts.Close
Else
Call count2 ' Mycounter2
s = ts.ReadLine
Form1.Text1.Text = s
ts.Close
End If
End Sub
Trouble Reading Line By Line From A Text File
This is what i have in a text file:
1ZOOMETRIC (12) S J MILLER (56)$ 6.70$ 6.20$ 4.70$ 4.90$ 2.40
2SHIRAZAMATAZZ (6) D J STAECK (56)$ 4.00$ 4.30$ 4.30$ 4.40$ 2.00
3CONSPIRATOR (3) G L SMITH (56)$21.80$20.60$22.20$22.70$ 6.20
4KING CANUTE (11) J S WHITING (56)$44.50$47.90$50.10$53.10$10.00
5WOOL ZONE (9) P KING (56)$22.50$20.50$22.40$21.40$ 5.70
This is the code I have:
Open "c:Test.txt" For Input As #2
Do While Not EOF(2)
Line Input #2, strLine
If Len(strLine) > 30 Then
a = Len(strLine) - 11
b = Mid(strLine, a, 5)
End If
Loop
Close #2
txtOutput.Text = b
I'm trying to get it to read a line and then put the result in a RichTextBox.
Then read the next line and put the result in the RichTextBox, and so on.
The code i have only returns the result from the last line ignoring the rest e.g. "21.40"
Thanks
lurch
Capture Api Line Images And Image.line Question
how do i capture picture of my graph plotted by the polyline function(attachment below) and can anyone tell me more about image1.line command and how do i draw circle on an imagebox.
Thanks
Richtextbox : How To Change/set A Line Position To Move The Line Up/down?
I want to write a line in a Richttextbox at a specific desired Position vertically, like in a picturebox.
For a picturebox to change the print position
Code:
Private Sub Command1_Click()
Picture1.CurrentY = 100
Picture1.Print "test" ' this prints the text beginning from y axis of
' 100 pixels down.
End Sub
How can I do the same for a RTBox?
(I dont mean a newlinefeed.)
If there is a solution for this, then I should place a text in a RTBox at
any position.
Ensuring Only 65 Chars Per Line In Multi Line Textbox
I have a text box that can have any number of lines, but each line can only have 65 characters (I'm using the SendMessage API). A blank space is treated the same as a character. Right now I'm adding a carriage return at every 66th character, which works fine if I don't go back and insert or change anything I already typed in. When I do try that the cursor gets put the end of all of the text in the text box. The only way to change any text is to back space to the point where I want to retype something.
I'm curious to know if anyone can give me some ideas about how I should go about doing this.
Thanks.
I'll post my code and you will see why I get pushed to the end of the text
Private Const EM_LINELENGTH = &HC1
charcount = SendMessage(txtDetails.hwnd, EM_LINELENGTH, txtDetails.SelStart, ByVal 0&)
txtDetails.Text = Left$(txtDetails.Text, InStrRev(txtDetails.Text, " ")) & vbCrLf & Mid$(txtDetails.Text, InStrRev(txtDetails.Text, " ") + 1)
txtDetails.SelStart = Len(txtDetails.Text)
Put Specified Line By Line Number Of A Text File Into String
All I need is to put a specified line of text from a text file (by line number) into a string. Thanks
Edit: Ill explain better
example:
Code:
open "cool.txt" for input as #1
getline 3, string '<--- puts line 3 into a string called "string"
close #1
Something to that effect. Thanks again.
|