Notice: this course covers
the older Visual Basic 6.0 programming application. Microsoft no
longer sells VB6. If you want to learn VB6, you'll have to find a used
copy somewhere like eBay or Craigslist. We will be updating this course
for use with Visual Basic 2013 soon. If you've purchased this
course within the last year, you'll get a free upgrade when it's
released.
This course follows VB107.
We'll cover one of the most important topics yet: reading and writing
text files. We'll start out learning how to write a text file. We'll
learn about the Open, For Output As, Print #1, Close #1, and
FreeFile commands.

We'll keep the first example easy - enter a
customer's name
and a filename, and save the data to the file.
Now that we know how to save data to a file, we'll
learn how to read it back in. We'll learn about the Open For Input
command, Line Input, creating our own subroutine, and the Shell command.

Our program has gotten more sophisticated.
We can save the
data to a file, load it back in, and View it with the Notepad
application
using the Shell command to launch a program. The program also
saves the size of the form too - so the next time it loads to the
same size
Next we'll learn how to save multiple items.
We'll load up a bunch of customers into a ListBox and then save all of
those items to a file.

Now we can type in a customer, add him to
the listbox, and then
save the entire contents of the listbox at once.
In this lesson we'll also learn about the
TabIndex property which is how you control your Tab Order - the
order in which you move between fields when you press the TAB key on
your keyboard.
Next, we need to learn how to read this list of
customers back in when the program starts, so we'll learn how to
fill the listbox back up from our saved records.
This means we will need to learn how to break up a
delimited string into its individual parts. We'll learn about the
InStr function and EOF marker. We'll learn the With keyword,
and how to send a parameter to a sub.

Breaking down comma-delimited strings is
easy once you know InStr
I know the screenshots from this class don't look
exciting, but we cover a lot of great material in this class.
Learning how to read and write information to disk is extremely
important, and is a fundamental method of making your programs work.
|