Solved

Reading Sequencial file line by line

Posted on 1998-09-10
2
164 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

729 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