Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Print Columns

Posted on 2000-04-19
7
Medium Priority
?
181 Views
Last Modified: 2010-05-02
I need simple code to access a delimited text file on "A:" Drive and print the contents in 5 columns.  Need to display with no delimiter characters.

Sample of Data:
"B105","LOFTIS BALL","300 BOHLING LANE", 8223.30, 7.70
0
Comment
Question by:mad3654
[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
  • 5
7 Comments
 
LVL 9

Expert Comment

by:Ruchi
ID: 2733218
Try something like this...

Private Sub Command1_Click()
    Open "A:\test.txt" For Output As #1
    Print #1, "B105", "LOFTIS BALL", "300 BOHLING LANE", 8223.3, 7.7
    Close #1
End Sub
0
 
LVL 4

Expert Comment

by:TigerZhao
ID: 2733228
Private Sub Command1_Click()
    Dim fn As Integer
    Dim s As String
    Dim v As Variant
    fn = FreeFile()
    Open Text1 For Input As fn
    While Not EOF(fn)
        Line Input #fn, s
        v = Split(s, ",")
        Printer.Print Join(v, vbTab)
    Wend
    Close fn
End Sub
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2733239
Or, you can write

Private Sub Command1_Click()
    Open "A:\test.txt" For Output As #1
    Print #1, Tab(10); "B105";
    Print #1, Tab(25); "LOFTIS BALL";
    Print #1, Tab(40); "300 BOHLING LANE";
    Print #1, Tab(55); 8223.3;
    PRint #1, Tab(70); 7.7
    Close #1
End Sub



0
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!

 
LVL 9

Expert Comment

by:Ruchi
ID: 2733308
Tab - to move to the specified column in the line so the next value can be ..output to start at that column position.

Print# - to write data to the specified any text, data file.

Write# - to add delimiters and separators
0
 

Author Comment

by:mad3654
ID: 2733906
I need code to access a delimited text file on "A:" Drive and print the contents in 5 columns.  Need to display with no delimiter characters.


I need something more like

Open "A:VB5.dat" for input as #1
Do While not EOF(1)

 "I am not sure what goes here something like- Line input #1, ID, Pname, Address, Due, Bal"?

Print ID, Pname, Address, format _(Due, "currency"), format(Bal, currency)
loop

end sub

I am opening a Data file named VB5.dat
Sample of data:

"B105","LOFTIS BALL","300 BOHLING_ LANE", 8223.30, 7.70
0
 
LVL 9

Accepted Solution

by:
Ruchi earned 200 total points
ID: 2735412
Oh, you want to read the data from the floppy disk...

Try this one.

Private Sub Command1_Click()
    Dim a As String
    Dim b As String
    Dim c As String
    Dim d As Single
    Dim e As Single
   
    List1.Clear
   
    Open "C:\test.txt" For Input As #1
   
    Do Until EOF(1)
        Input #1, a, b, c, d, e
        List1.AddItem (a & vbTab & b & vbTab & c & vbTab & Format$(d, "currency") & vbTab & Format(e, "currency"))
    Loop
    Close #1
End Sub
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2735419
I meant "c:\text.txt" to "A:\test.txt"
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses

704 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