Reformatting a student records text file in Visual Basic

  • Thread starter Thread starter neutrik
  • Start date Start date
  • Tags Tags
    Visual
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 4K views
neutrik
Messages
1
Reaction score
0
Hi,

I no very little about visual basic yet I need to write a program that will format some text. A simple enough task that shouldn't take long to complete...

Basically I'm given a text file with something like

Code:
Smith John  HIS  GEO  ENG  MUS  GST 06/03/85
Blake Nathan  MAT  HIS  MUS
Hunter Matt  GER  PHY  12/12/86

and I need to write a function that will format the line so it writes a new text file as shown below.

Code:
FIRST NAME   SURNAME       DOB          AS1    AS2    AS3    AS4    AS5   
John         Smith         06/03/85     HIS    GEO    ENG    MUS    GST
Nathan       Blake                      MAT    HIS    MUS
Matt         Hunter        12/12/86     GER    PHY

I can show someone what I've done so far (it will open and read the text file) but I just don't know how to write the function since my ability to write in VB is limited and I need to have this completed by Friday. I tend to leave things till the last minute, yes I'm an idiot.

If someone could help me out at bit it would be cool if you could email me at neutrik007@yahoo.com
 
Physics news on Phys.org
Ok use the
Space (20 ) or

' The Tab function can be used with the Print # statement.
Open "TESTFILE" For Output As #1 ' Open file for output.
' The second word prints at column 20.
Print #1, "Hello"; Tab(20); "World."
' If the argument is omitted, cursor is moved to the next print zone.
Print #1, "Hello"; Tab; "World"
Close #1 ' Close file

Rahul