Visual Basic Help: Formatting Text File

  • Thread starter Thread starter neutrik
  • Start date Start date
  • Tags Tags
    Visual
Click For Summary
SUMMARY

The forum discussion centers on formatting a text file using Visual Basic (VB). The user needs to transform a raw text file containing names and subjects into a structured format with specific columns for first name, surname, date of birth, and subjects. Key techniques discussed include using the Print # statement and the Tab function to control output formatting in VB. The user seeks assistance in writing a function to achieve this formatting by a deadline.

PREREQUISITES
  • Basic understanding of Visual Basic programming
  • Familiarity with file I/O operations in VB
  • Knowledge of string manipulation techniques in VB
  • Understanding of formatting output in VB using Print # and Tab functions
NEXT STEPS
  • Research how to manipulate strings in Visual Basic
  • Learn about file handling in Visual Basic, specifically using Open, Print, and Close statements
  • Explore the use of arrays in Visual Basic for organizing data
  • Study examples of formatting output in Visual Basic to enhance presentation
USEFUL FOR

This discussion is beneficial for beginner Visual Basic programmers, students learning file manipulation, and anyone needing to format text files programmatically.

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
 

Similar threads

  • · Replies 27 ·
Replies
27
Views
24K