Computer Learning Zone CLZ Access Excel Word Windows

Sleep can interfere with opportunity.

-103rd Rule of Acquisition
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Home > Courses > Visual Basic > VB 6 > 201 > Introduction < 201 | Lesson 01 >
Introduction

Welcome! Text Files: Read, Write, Strings


 S  M  L  XL  FS  |  Slo  Reg  Fast  2x  |  Bookmark  |  Autoplay: ON

In this lesson, we will introduce Visual Basic 201 and discuss how to read and write sequential text files, break up delimited strings, and use string functions like InStr, Left, and Right. We will also look at the Tab Index and Tab Stop properties, and show how to send parameters to your own subroutines. The class is based on Microsoft Visual Basic, and familiarity with Visual Basic 107 is recommended. We will cover how to access course materials and participate in the class discussion forum, and you will get tips for following along with the sample projects.

Navigation

Keywords

, read text files, write text files, sequential text files, delimited strings, string functions, InStr, Left, Right, Tab Index, Tab Stop, subroutine parameters, Visual Basic 6.0, VB6, VBLearningZone

 

Start a NEW Conversation
 
Only students may post on this page. Click here for more information on how you can set up an account. If you are a student, please Log On first. Non-students may only post in the Visitor Forum.
 
Subscribe
Subscribe to Introduction
Get notifications when this page is updated
 
More Information
Transcript 
Welcome to Visual Basic 201 brought to you by VBLearningZone.com. I am your instructor, Richard Rost.

In today's class, we are going to learn how to work with text files. We will learn how to read and write sequential text files. I will teach you how to break up delimited strings. We will learn a lot of string functions including InStr, Left, and Right string. We will learn about the Tab Index and Tab Stop properties. We will also learn how to send parameters to our own subroutines.

The prerequisite for this class is Visual Basic 107. I strongly recommend you take 101 through 107 before taking this class.

There is a web page for this class located at VBLearningZone.com. Question mark, GO VB201. On this page, you will find sample project files, the course outline, and the student discussion forum. If you have any questions about the material covered in today's class, post them here on the discussion forum.

If you are watching this class in the Amocrine Video Player or the Online Theater, you will see this page load up to the right of the videos. Join in the discussion by posting your thoughts there.

In today's class, I will be using Microsoft Visual Basic 6.0. If you are using a different version of VB, such as VB.NET or VB2005, you will find that the interface is different. However, most of the Visual Basic programming code will work just fine.

I strongly recommend you sit back, relax, and watch each video through once without doing anything. Then, replay the video again and follow along with the examples, building each project as I do. Do not try to apply what you are learning immediately to other projects that you might be working on. Instead, build the sample project in class with me.
Intro 
In this lesson, we will introduce Visual Basic 201 and discuss how to read and write sequential text files, break up delimited strings, and use string functions like InStr, Left, and Right. We will also look at the Tab Index and Tab Stop properties, and show how to send parameters to your own subroutines. The class is based on Microsoft Visual Basic, and familiarity with Visual Basic 107 is recommended. We will cover how to access course materials and participate in the class discussion forum, and you will get tips for following along with the sample projects.
Quiz 
Q1. What is one of the main topics covered in this Visual Basic 201 class?
A. How to work with text files
B. How to create databases
C. How to animate graphics
D. How to use SQL Server integration

Q2. Which string functions will you learn in this class?
A. InStr, Left, and Right
B. Sum, Average, and Count
C. Find, Replace, and Split
D. Trim, Proper, Upper

Q3. What is recommended before beginning Visual Basic 201?
A. Completing Visual Basic classes 101 through 107
B. Reading the official documentation only
C. Installing the latest version of Windows
D. Learning Python scripting

Q4. What should you do if you have questions about the course?
A. Post them in the student discussion forum
B. Email the instructor directly
C. Call technical support
D. Wait for the next class

Q5. Which Microsoft Visual Basic version is being used in the videos?
A. Microsoft Visual Basic 6.0
B. Microsoft Visual Basic for Applications
C. Microsoft Excel VBA
D. Microsoft Access VBA

Q6. What should students do FIRST when watching the videos?
A. Watch the video through once without doing anything
B. Build the projects as they watch the video the first time
C. Take detailed notes during the first viewing
D. Apply the concepts to their own current projects

Q7. Where can students find sample project files and course outlines?
A. On the class web page at VBLearningZone.com
B. Included with the video downloads
C. On Microsofts official website
D. Through email attachment

Q8. What is one of the properties discussed in this class?
A. Tab Index and Tab Stop
B. Font Color and Background Style
C. Cell Height and Width
D. Form Caption and Border Style

Q9. Which statement is TRUE about following the class structure?
A. Build the sample project in class with the instructor
B. Skip the sample project and practice on other files
C. Focus only on theory, not practical application
D. Use only code samples you found elsewhere

Q10. What should you NOT do when first learning from this class?
A. Try to immediately apply what you learn to unrelated projects
B. Follow along and build the sample project
C. Participate in the discussion forum
D. Re-watch the videos for practice

Answers: 1-A; 2-A; 3-A; 4-A; 5-A; 6-A; 7-A; 8-A; 9-A; 10-A

DISCLAIMER: Quiz questions are AI generated. If you find any that are wrong, don't make sense, or aren't related to the video topic at hand, then please post a comment and let me know. Thanks.
Summary 
Today's video from Visual Basic Learning Zone focuses on working with text files in Visual Basic 6.0. I'm Richard Rost, your instructor for this course.

In this lesson, we will explore how to handle text files by reading from and writing to sequential files. I will show you methods for breaking apart strings that use delimiters and introduce you to some valuable string functions, including InStr, Left, and Right. We will also spend some time learning about the Tab Index and Tab Stop properties, helping you control the navigation order of controls on your forms. In addition, I will demonstrate how to pass parameters to your own subroutines.

Before starting this course, you should have completed Visual Basic 107. Ideally, I recommend you work your way up through Visual Basic 101 all the way to 107, as each class builds upon the knowledge gained in previous lessons.

There is a specific web page dedicated to this class at VBLearningZone.com. There you will find downloadable sample project files, a full outline of the course, and a discussion forum where you can ask questions and participate in conversations with fellow students. If anything in the class is unclear or you want to share your thoughts, please join the discussion on the forum.

If you are watching this lesson using the Amocrine Video Player or from the Online Theater, you will see the course webpage showing up next to the video. Feel free to participate in discussions there as well.

Throughout this lesson, I will be demonstrating everything in Microsoft Visual Basic 6.0. If you are using Visual Basic .NET, Visual Basic 2005, or any other newer version, you will notice the interface has changed. However, most of the programming concepts and code shown in this lesson will still apply and work in your version.

My recommendation is that you watch each video lesson straight through before you try anything yourself. Then, watch it again and follow along step by step, building out the sample project as I do in the video. Focus on duplicating the exact project from the lesson first before trying to apply these new concepts to your own personal projects.

You can find a complete video tutorial with step-by-step instructions on everything discussed here on my website at the link below. Live long and prosper, my friends.
Topic List 
Reading sequential text files

Writing sequential text files

Breaking up delimited strings

Using InStr function

Using Left function

Using Right function

Tab Index property

Tab Stop property

Sending parameters to subroutines
Article 
Welcome to this tutorial on working with text files in Visual Basic. In this lesson, we will focus on how to read and write sequential text files, break up delimited strings, and use useful string functions like InStr, Left, and Right. We will also discuss how to use Tab Index and Tab Stop properties for organizing form navigation, and how to pass parameters to your own subroutines.

To get the most out of this tutorial, you should already be familiar with the basics of Visual Basic, including working with variables, creating forms, and basic controls. If you need to review the basics, consider starting with introductory materials before moving on.

Let us begin by discussing text files. Often when working with applications, you need to read data from or write data to external text files. These can be simple sequential files where data is stored line by line. You might use text files to import lists, store logs, or export data for other programs to read.

To write data to a text file, you use the Open statement, specifying the file name and the mode. For example, to create a new file and write to it:

Dim FileNum As Integer
FileNum = FreeFile
Open "C:\MyFolder\example.txt" For Output As #FileNum
Print #FileNum, "This is a line of text."
Print #FileNum, "Here is another line."
Close #FileNum

In this code, FreeFile provides the next available file number. The string given to Open is the path of the file you are writing. Using For Output creates a new file or overwrites any existing file with the same name. The Print statement writes each line to the file. Remember to use Close when you are done to free resources.

To read data from a text file, use the Input or Line Input statements. Here is how you can read each line from a file and display it in a message box:

Dim FileNum As Integer
Dim strLine As String
FileNum = FreeFile
Open "C:\MyFolder\example.txt" For Input As #FileNum
Do While Not EOF(FileNum)
Line Input #FileNum, strLine
MsgBox strLine
Loop
Close #FileNum

The EOF function checks for the end of the file, and Line Input reads one line at a time into the string variable strLine.

Text files often store information separated by a specific character, such as a comma or tab. These are called delimited strings. For example, a line might look like this:

John,Doe,30,New York

To break up (or parse) these strings, use the Split function. For instance, to separate names and other data using a comma as the delimiter:

Dim arrFields() As String
arrFields = Split(strLine, ",")

Now arrFields(0) will have "John", arrFields(1) will have "Doe", and so on. You can then use each value as needed in your program.

When working with strings in Visual Basic, three useful functions are Left, Right, and InStr. The Left function returns a specified number of characters from the left side of a string. For example:

Dim firstName As String
firstName = Left("Johnathon", 4) ' firstName is now "John"

The Right function does the same but from the right end:

Dim lastFour As String
lastFour = Right("1234567890", 4) ' lastFour is now "7890"

The InStr function finds the position of one string within another. For example:

Dim pos As Integer
pos = InStr("hello world", "world") ' pos will be 7

This is helpful when you need to find where a substring starts in a larger string, such as checking for delimiters or specific keywords.

Organizing form navigation is easier with the Tab Index and Tab Stop properties. Tab Index controls the order in which controls receive focus when the user presses the Tab key. Set the Tab Index of each control to determine the order. Lower numbers take focus first. The Tab Stop property can be set to False to prevent a control from receiving focus via the Tab key, which is useful for labels or images that do not need direct interaction.

Finally, you can make your code more reusable by sending parameters to your own subroutines. For example, if you have a subroutine to display a message, you can define it like this:

Sub ShowMessage(msg As String)
MsgBox msg
End Sub

Call this subroutine from anywhere in your program by passing the desired message:

ShowMessage "Welcome to the program!"

By using parameters, your procedures become more flexible and easier to maintain.

In summary, this tutorial introduced the main techniques for working with sequential text files in Visual Basic, manipulating and parsing strings, organizing form navigation, and creating your own parameterized subroutines. Practice these examples to build your understanding and try creating a small project that reads from a file, parses each line, and displays results on your form. This hands-on approach will help reinforce what you have learned.
Primary Topics 
text file input/output, delimited strings, string functions, Tab Index, Tab Stop, subroutine parameters
Secondary Topics 
student discussion forum, project practice
 
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 8/9/2026 6:31:16 PM. PLT: 1s
Keywords: , read text files, write text files, sequential text files, delimited strings, string functions, InStr, Left, Right, Tab Index, Tab Stop, subroutine parameters, Visual Basic 6.0, VB6, VBLearningZone  PermaLink  How To Read and Write Text Files and Work With Strings in Microsoft Visual Basic