Solved

Reading Sequencial file line by line

Posted on 1998-09-10
2
156 Views
Last Modified: 2010-04-30
VB command to read a sequencial file line by line in a buffer without losing any spaces.
the file contains 79 long records per line. I want to read
each line in a variable that ends up to contain 79 chars including spaces.
thanks
0
Comment
Question by:g6yassin
2 Comments
 
LVL 2

Accepted Solution

by:
wj7ster earned 20 total points
ID: 1434215
Your question is a little vague....If I understand you correctly you can try this:

Dim sLine     As String

' * * * * * * *

Open pathtofile For Input As #1

While Not EOF(1)
 Line Input #1, sLine
Wend


0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1434216
Hi,
If you want to have all the lines in an array or a textbox
here is a small code for it.

=========== START CODE =============

Private Sub Command1_Click()
Dim OneLine$
Dim AllLines$
Dim inFile
Dim Wrap

Wrap = Chr$(13) & Chr(10)

'* you can use this to open a file or
'*(you need a component: COMDLG32.OCX) >>>
'* CommonDialog1.ShowOpen
'* Open CommonDialog1.filename For Input As #1

'* >>> You can use this to open a file
'* path(myFolder) and file name (myFile.txt)
inFile = "c:\myFolder\myFile.txt"
Open inFile For Input As #1

While Not EOF(1)
    Input #1, OneLine
    AllLines = AllLines & OneLine & Wrap
Wend

Close #1
Text1.Text = AllLines '* (Make Text1.text MultiLine=true)
End Sub


======== END CODE ========


Notes:

1. The Textbox limited to 32 KB.

2. You can use array like A(i) to hold the lines one by one but    than you need to count the number of lines first.

3. You can write to a new file (post if you need the code).

- What do you want to do with the lines?

I hope it helps some.

Shay.


0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Share codes 68 115
Excel Formula to Pull Data from Text String 7 67
vb6 connector to mongodb 2 29
Hide vba in gp 7 48
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now