Visual Basic (MS Excel)

Exercise 3 - Writing to Files

  1. Start Excel and create a userform
  2. Place the following on the userform:
  3. Now write the following event SUB
  4. Run the program.
  5. Click on Create File.
  6. Enter in data in the text boxes and click on Write to File
  7. Do step 6 several times.
  8. Click on Close.
  9. Using Microsoft WordPad or Word open the file called test.txt on your drive h: and have a look at it.

Assignment 3

Create a user form with 3 textboxes for name, address and telephone number. Create the buttons required to create a text file for storing data in, storing each record and then closing the file. Run the program and use the form to enter 4 sets of data in a file on your drive h:

Save the whole spreadsheet as VB3.xls on your drive h:

If you have any problems with understanding the instructions on this page you could email Brian Mulligan who will try to improve the page for future users and may be able to give you some help in the meantime.

Back to Visual Basic Index