Copying A Complete Text File 1 Line At A Time
I'm working on a program that will need to load an entire text file into a mainframe application one line at a time. The text file is 77 characters wide and the mainframe system is 80 characters wide, so it will fit without any issues, I'm just trying to figure out the best way to code it to be uploaded. The mainframe system will only accept one line at a time, so the end result needs to be:
VB Code: Sess0.Screen.Sendkeys(line1 + "<enter>")Sess0.Screen.Sendkeys(line2 + "<enter>")Sess0.Screen.Sendkeys(line3 + "<enter>")Sess0.Screen.Sendkeys(line4 + "<enter>")'etc. etc. etc.
The issue is that each text file will be between 200 & 300 total lines but never the same amount. Is there a way I can set an array up to loop & define as many objects as it needs for each file on a case by case basis? Instead of initially defining it as line(300) or something like that I mean?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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
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 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 & "
otice 2331.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?
Reading Text File 1 Line At A Time
Okie So far i figured out that if you just use Input #FF, <Variable>
It only reads the 1st line
Now I got a Server and a Client
Server is the one reading the Multi Lined Text File
It sends the Strings 1 line at a time
Client gets them with winsock and Additem with a list so it comes out in a good order
Right now i have this and it wont work cus its in one long line instead of 20 lines it comes in 1 big one
Can you Help me out this is what i got now? How Can i make ti so it adds item everytime theres a new line
Code:
'Server
Dim txt As String
Dim FF As Integer
Dim i As Integer
FF = FreeFile
Open "c:Input.txt" For Input As FF
Do While Not EOF(FF)
'Line Input #FF, txt
Input #FF, txt
RemoteShell.SendData txt
Loop
Close #FF
DoEvents
'Client
Private Sub RemoteShell_DataArrival(ByVal bytesTotal As Long)
RemoteShell.GetData data, vbString
CmdOutput.AddItem data
End Sub
Thanks
Reading A Text File One Whole Line At A Time
Using the procedure "Open FileName for Input as #1", how do I read one complete line at a time? I'm using "Input #1, strInput" but any delimeters in the line tends to break it up as separate values for the strInput variable.
Thanks
Reading In A Text File One Line At A Time
I am trying to read in one line of a text file at a time, basically, the text file will be full of numbers, but i want to read in one line at a time and display it in a text box, i can read in a full text file in one go but i dont know how to read in one line at a time, here is the code that reads in the whole text file, any help would be great, thanks....
'code:
Dim line As String
Open Filename For Input As #1
Do While Not EOF(1)
Input #1, line
Text1.Text = Text1.Text & vbCrLf & line
DoEvents
Loop
Close #1
Match Text Box Value In Text File (complete Code Please)
i have text file like this
<B>john bredman</B><BR>
,SUMIT,TORONT,PENSIL,COMDEX,PERU,BANG
Phone: +92 (51)123-8784521<BR>
Fax: +92 (51)123-8784521<BR>
Email: <A href="mailto:ABC@hotmail.com"></A>
when i wirite in text box "john bredman" then it should search in text file and ignore "<B>,</B>,<BR>" and message appear that "string is found".
OR
if i write string "COMDEX" in text box and i press button to search in text file, if string is found in text file then message should appear that "string is found"
How Search Complete Value Of Text Box In Text File (some Code Please)
hi
some body please give me some code stuff for, when i enter a string value in text box then this value should be searched "as a whole word" in text file. or i clear this question that, when i enter in text box then all of the text box value should be match in text file.
thanks
Want A Complete API Text File....help
I use API many times and i need to know all the constants
and their values in order to use them.
There are lots of constants and API's which are not listed in API
Viewer. Therefore i have to refer to some book or i have to find the values of the constants on the net.
Is there any way out for this?
.....(May be a complete API.txt file listing most of the API's and constants?)
If somebody have it, and ready to share, i will be very thankful to him/her.
Thanks guys.
Input Not Getting Complete Text File
I am using an Input statement to retrieve a text file (actually a PDB file from my Palm saved on syncing the device). I wish to parse it in my vb app. I am only getting the first 15 chars. up to a hex A6 character. Any thoughts on how I can retrieve the whole file. Thanks Bruce
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 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@
Copying A File A Byte At A Time
I'm wanting to copy a file a byte at a time and create a progress bar in my app i've written.
At the moment I'm using the FileCopy command. When copying files larger then say 100mb over the network, my app locks up until the file has been copied.
I know how to do a progress bar but struggling with copying the file.
Can anyone help me?
Thanks
Multi Line Text File Single Line Text Box
Hi i have this code but it is missing some thing and i cant see what
it writes a line in a dat file this is ok but i want it to add a new line with text from a text box one after the other like pressing return in a word doc
Open App.Path & "lcount.dat" For Output As #3
Print #3, txtBody.Text
Close #3
Please Give Me Complete Source Code For Searching In Text File In Described Criteria
i have many paragraphs with different strings in text file, i am going to search the value of textbox in text file.
the text file looks like this
<B>Don Man</B><BR>
,SUMIT,TORONT,PENSIL,COMDEX,PERU,BANG
office 14, street18, hangten villa, toronto.
Advisor, Engineer
Phone: +92 (51)123-8784521<BR>
Fax: +92 (51)123-8784521<BR>
how do i print the following string
SUMIT
TORONT
PENSIL
COMDEX
PERU
if the value "office 14" OR the other value as like "8784521" OR "advisor engineer" OR "Don Man" is entered in the text box.
Copying And Renaming A File With The Date/time In The Filename
Hi there,
I've never done much with VB as far as moving files aroudn and such and am hoping someone cna whip me up what I think wuld be a very simple little program.
All it would do would be every hour, take a file from a particular folder, copy it to a different folder, and rename it and add the date/time onto the filename somehow.
So a file called Database.mdb would get changed to database 031420021100 for March 14th, 2002 at 11:00. It doesn't have to be that format, just an example.
Can someone give me the couple lines I'm guessing it would take to do that?
THanks,
-Mike
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
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
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
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.
Reading A Text File Line By Line For Spellcheck
i am building a word processor. i want to build a fairly basic spellchecker. i will create a txt file with a line by line list of words that can be used and want to check each word against this. i can get a array with all the words in the program and the txt file with the dictionary in it. anyone point me in the right direction on how do this. possibly in a loop but not sure. Thanks
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
Searching For A String In A Text File Line By Line
eiSecure: The following code will work with single instances of the ~BEGIN and ~END tags, but it doesn't work with multiple instances (but you should be able to add it in if you play around with it for a bit).
VB Code:
Dim sFile As StringDim saFile() As StringDim strText As String Open "MyFile.txt" For Input As #1sFile = Input(LOF(1), 1)Close #1 saFile = Split(sFile, vbCrLf) For y = 0 To UBound(saFile) If Trim$(saFile(y)) = "~BEGIN" Then For x = y To UBound(saFile) If Trim$(saFile(x)) = "~END" Then For Z = y + 1 To x - 1 strText = strText & saFile(Z) & vbCrLf Next Z strText = strText & vbCrLf End If Next x End IfNext y Text1 = strText
Reading A Text File Line By Line ***RESOLVED***
Hi all,
I'm sure this is not as complicated as I'm making it but...
I'm trying to read a text file line by line
the text file consists of lines of data separated by commas... such as:
10,1.3,RP,15/12/00,,,,,,,
11,FF,,,SjR,15/12/00,09:26,0,,,
My code returns "10" then "1.3" then "RP" etc
I want it to return "10,1.3,RP,15/12/00,,,,,,," then "11,FF,,,SjR,15/12/00,09:26,0,,,"
VB Code:
'Open text fileOpen sFilePath For Input As #1'Loop through rowsDo While Not EOF(1) Input #1, sCurrentLine MsgBox sCurrentLineLoopClose #1
Can anyone help pls.
Copying A Text Box To A Txt File.
On the form there will be 2 text boxes and 1 command button. I want the code for when the command button is pressed it will copy the information in the text box to a file called result.txt without opening this file. I want it to copy the first text box to the first line of the file and the second onto the second line but if the button is clicked twice it will put the first text box onto the 3rd line and so on without replacing the other lines.
Replacing Text In Text File, Line For Line
Hey guys,
this successfully copies the text from file 1 to file 2, but weird, this is the original
Code:<style resid=wpdropdownss>
element
{
fontface: ifhc(sysmetricstr(2), rcstr(2016));
fontsize: ifhc(sysmetric(-4), rcint(2015) pt);
and this is the appended.. same text just not the same format, any suggestions? my code is at the bottom, i've only been coding in vb for a few days
Code:<style resid=wpdropdownss>
element
{
fontface: ifhc(sysmetricstr(2)
rcstr(2016));
fontsize: ifhc(sysmetric(-4)
rcint(2015) pt);
Code: Dim data As String
Open "D: 1_1853.txt" For Input As 1
Open "D:
ew.txt" For Append As 2
Do Until EOF(1)
Input #1, data
Print #3, data
Loop
Do Until EOF(2)
Input #2, data
Print #3, data
Loop
Close #1
Close #2
Edited by - Ahmz_055 on 12/3/2004 12:02:09 PM
How To Read A Line At A Time From A Text?
i have a file and i want to read one line at a time from it and send it
the file has inside the following...
oneline
secondline
thirdline
i want to open the file and read from inside the first line that sais "oneline" and send it...then the second then the third...
Reading A Text File Line By Line
How would i read a text file line by line?
so far i have
Open est.txt" For Input As #1
but i dont know how to read the file into a variable =/ *confused*
Reading Text File Line By Line
I have a text file with X number of lines in it and I want to open the file, read the first line, do something with the first line, read the next line, do something, etc.. until the end of the file.
Right now I have something like this:
Code:
WorkFile = FilePath & FileName
Open WorkFile For Input As #1
Do While Not EOF(1)
strData = Input(LOF(1), 1)
Debug.Print strData
Loop
Close #1
When I do this, it is putting the entire file in strData and not each line. Any ideas, I am sure this is simple, but I am just not getting it.
Thanks.
Line By Line Reading A Text File
Hi I want to read a set of Telephone numbers from a text file. Tel numbers are in Line by line. Therefore i want to read it line by line from a Text file
1. ) How can i do this...?
2) Without using FileSystemobject, is there are any Vb built in commands for this...?
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
Write Line By Line In Text File...
i people somedoby can tellme how i can create a public funciton for write e file with 12 lines?
exemple
256986 - line1
569856 - line2
454884 - line3
thanks all best regards...
Reading Text File Line By Line
Hey there guys, i posted here just a few minuits ago, but it seems I hit another problem.
I have this code:
VB Code:
Private Sub Command1_Click()Dim hFile As IntegerDim strContents() As StringDim lngElement As Long Dim a, b hFile = FreeFileOpen "C:helo.txt" For Input As #hFile'Do While Not EOF(hFile)ReDim Preserve strContents(0 To lngElement)Line Input #hFile, strContents(lngElement)lngElement = lngElement + 1'LoopClose #hFile a = Split(strContents(0)) Me.Text1.Text = a(0)Me.Text2.Text = a(1) b = Split(strContents(1)) Me.Text3.Text = b(0)Me.Text4.Text = b(1)Me.Text5.Text = b(2) End Sub
But what it is doing is reading spaces with it, eg.
text file=
---------
john eats
long day today
text1 = john
text2 = east
text3 = long
text4 = day
text5 = today
So how do i change it so it does this:
text1 = john eats
text2 = long day today
Please help, thanks...
Reading Text File Line For Line
I have a textfile which I need to get data from. the format is:
something = number
something else = number
something different = number/string
something = number
...
As you can see some of the texts of the left of the = are repeated, this mean I can't do a instring function. How do I read the file line for line?
Text File Help - Reading Line By Line
I have a text file with X number of lines in it and I want to open the file, read the first line, do something with the first line, read the next line, do something, etc.. until the end of the file.
Right now I have something like this:
WorkFile = FilePath & FileName
Open WorkFile For Input As #1
Do While Not EOF(1)
strData = Input(LOF(1), 1)
Debug.Print strData
Loop
Close #1
When I do this, it is putting the entire file in strData and not each line. Any ideas, I am sure this is simple, but I am just not getting it.
Thanks.
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!!
Reading A Text File From Line X To Line Y
Hi, I know how to loop through a file and get all the lines and how to loop from say line 1 to line whatever. But what I'm trying to figure out is how to start the loop from some where inthe middle of the file, Line 100 for example and read from there on. Thanks for your help with this.
-Sam
Clipboard Copying From Text File
I have a text file and I have not been able to copy all the data in that text file to the clipboard, it just takes the first line and thats it. I can't think of what to do, I know what the problem is I just can't fix it. It is just inputting one line of text onto the clipboard each time and not moving through all the lines and adding them all. Thanks to anyone who can help me.
Running Text In My Program, One Line At A Time.
Ok, ive asked friends looked in my books, and have come to no avail as to how to accomplish this.
What I am trying to do is, load a text file, and put the contents in text3, this I have already accomplished. Once the text is loaded, I need to make a loop that will put one line from text3 into text1, and run Command1_click. Then it goes on to the next line in text3, puts it in text1, and does Command1_click, and keep doing this until it reaches the end of the text in text3. Can anyone help me to find a way to do this? Id appreciate it a lot.
Displaying Text One Line At A Time In Textbox.
well here it is folks,
I am in need of some help. I have a dirListbox and a FileListBox on a page. I need to be able to select a text file out of the FileListBox and have it Displayed in a textBox one line at a time with a next and previous button. these are not tab delineated, just standard text files. *.txt and all that.
HELP!!!!
here is the problem I have, I cannot get the FileListBox to select the File. If I could do that even, I could not get it to the TextBox. I need to be able to connect the File that is selected to the Textbox one line at a time. (better description.)
live long and perspire,
Milerky2-97
|