?
Solved

Reading Sequencial file line by line

Posted on 1998-09-10
2
Medium Priority
?
165 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 80 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

800 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