[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Reading Sequencial file line by line

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

649 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