Visual Basic Help: Formatting Text File

  • Thread starter Thread starter neutrik
  • Start date Start date
  • Tags Tags
    Visual
Click For Summary
The discussion centers on a request for assistance in writing a Visual Basic program to format text from a given input file. The user needs to transform lines of text containing names and subjects into a structured format with specified columns for first name, surname, date of birth, and subjects. The example provided illustrates the desired output format, highlighting the need to handle varying numbers of subjects and missing date of birth entries. The user has made some progress by opening and reading the text file but requires help specifically with the function to format and write the output correctly. A deadline for completion is mentioned, emphasizing urgency. The user also shares a snippet of code demonstrating the use of the Tab function in Visual Basic for formatting output.
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
 
Technology 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
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 27 ·
Replies
27
Views
23K