Computer Learning Zone CLZ Access Excel Word Windows

If it ain't broke, don't fix it.

-280th Rule of Acquisition
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 

Introduction

Welcome! Events, Properties & Forms Tips


 S  M  L  XL  FS | Slo Reg Fast 2x 

In this lesson, we will introduce Visual Basic basics, focusing on working with events and properties like GotFocus and LostFocus, using color constants, and understanding variable types and naming conventions. We will discuss functions including how to measure string length, explore the Select Case statement as an alternative to multiple If Then statements, and talk about events such as the Form Load event. We will also cover how to change form properties with code, adjust form startup behavior, and share tips for working with border style. Resources and community discussion options will be mentioned.

Navigation

Keywords

, Visual Basic 6, VB6 events, GotFocus, LostFocus, Form Load event, color constants, variable types, String, Date, Long, variable naming conventions, Select Case, Length function, form properties, border style, 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 103, brought to you by VBLearningZone.com. I am your instructor, Richard Rost.

In today's class, we are going to work with events and properties, such as GotFocus and LostFocus. We are going to learn how to work with colors, the different color constants. We are going to learn how to work with variables and the different variable types, such as String, Date, and Long. We will learn different naming conventions for variables.

We are going to learn a couple of functions, including the Length function, to see how to take the length of a string. We will learn about the Select Case statement, which is an alternative to long If Then blocks.

Continuing on with different events, we are going to learn about the Form Load event, which fires when a form first opens. We will learn how to change form properties using VB code. For example, the size of a form can be changed during your program.

We will learn a lot of little tips and tricks too. For example, how to change where your form starts up when your program loads, how to manipulate properties such as the border style, and lots of little tricks.

This class follows Visual Basic 102. I strongly recommend you take my VB 101 and 102 classes before taking this one. I will be using Visual Basic 6.0 in this class. If you are using a different version of Visual Basic, such as VB.NET or VB 2005, you will find the interface is a little bit different, but most of the code that I am using in class should work for any version of VB.

I suggest you sit back, relax, watch the video once the first time through, then watch the lesson a second time following along with the examples. I do recommend that you try to build the sample projects that I am building in class before you try to apply what you are learning to a project that you happen to be working on.

The class website for this particular course is at VBLearningZone.com?GOVB103. On that page you will find information about this class. You will also find our discussion web where you can talk about the topics in this class with me and other students.

If you happen to be watching this class in the Amicron Video Player or in the Amicron Theatre Online, you will find that this discussion form opens up just to the right of the video in the player. If you have any questions or comments about the class, post them there and everyone can join in.
Intro 
In this lesson, we will introduce Visual Basic basics, focusing on working with events and properties like GotFocus and LostFocus, using color constants, and understanding variable types and naming conventions. We will discuss functions including how to measure string length, explore the Select Case statement as an alternative to multiple If Then statements, and talk about events such as the Form Load event. We will also cover how to change form properties with code, adjust form startup behavior, and share tips for working with border style. Resources and community discussion options will be mentioned.
Quiz 
Q1. What event occurs when a control on a form gains the user's attention in Visual Basic?
A. GotFocus
B. Click
C. LostFocus
D. MouseOver

Q2. Which Visual Basic event triggers when a form is first opened?
A. Unload
B. Load
C. Resize
D. Activate

Q3. What is an alternative to using long blocks of If Then statements in Visual Basic?
A. For Next loop
B. Select Case statement
C. Do While statement
D. GoSub statement

Q4. Which of the following is NOT a variable type discussed in this class?
A. String
B. Date
C. Boolean
D. Long

Q5. What function can you use in Visual Basic to get the length of a string?
A. Count
B. Len
C. Size
D. Mid

Q6. If you want to change the starting position of your form when your program loads, what should you modify?
A. Form color property
B. Form border style
C. Form startup position
D. Form caption

Q7. Which of the following is a reason to use naming conventions for variables in Visual Basic?
A. To make code easier to read and maintain
B. To change the color of controls
C. To automatically generate event procedures
D. To control form size

Q8. What is a color constant in Visual Basic used for?
A. To let users select text fonts
B. To specify standard color values in code
C. To create arrays of strings
D. To select database connections

Q9. Which property of a form can be changed dynamically using Visual Basic code?
A. The project name
B. The form size
C. The Windows desktop wallpaper
D. The screen resolution

Q10. What should students do after watching the video the first time, according to the instructor?
A. Move immediately to applying lessons in their own projects
B. Watch the lesson again while following along with the examples
C. Take a written quiz
D. Skip to the next course

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

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 the Visual Basic Learning Zone is the third in our Visual Basic 6.0 series, where we're going to explore some fundamental yet powerful concepts that are essential for effective programming in VB.

In this lesson, I will be teaching you about events and properties, specifically the GotFocus and LostFocus events. These are important for controlling how your application responds when a user selects or leaves a particular control, like a text box. We'll also look at how to work with colors, covering both color constants and how you can manipulate colors directly within your VB applications.

An important part of any programming language is understanding variables and their types. In this class, we'll discuss the different types of variables available in Visual Basic, such as String, Date, and Long, and I'll show you some common naming conventions to help make your code more readable and maintainable.

We'll also review some useful functions, including the Length function, which allows you to determine how many characters are in a string. On top of that, I will introduce you to the Select Case statement, which is often more efficient than writing out long If Then blocks for multiple conditions.

Continuing with our discussion of events, I'll demonstrate the Form Load event, which is triggered when a form is first opened. You'll learn how to adjust form properties right from your code, including how to change the form's size programmatically as your application runs.

Along the way, I'll share a number of practical tips to make your life easier. These include setting where your form appears on screen when your application starts, tweaking various properties like the border style, and other useful shortcuts that help streamline your workflow.

This course builds on what was covered in Visual Basic 102, so if you're new to these topics, I highly recommend starting with my VB 101 and 102 classes first. Throughout this series, I am using Visual Basic 6.0, but the majority of the concepts and code examples will work in other VB versions like VB.NET or VB 2005, although the interface might look different.

My suggestion is to watch the video all the way through once to get a sense of the flow, and then go through it a second time - this time following along with your own sample projects. Building these examples yourself before applying them to your own projects will really help reinforce what you've learned.

For additional resources, head over to my website at VBLearningZone.com?GOVB103. There, you'll find more information about the class and a discussion forum where you can post your questions and interact with other students and with me.

If you are using the Amicron Video Player or watching online with Amicron Theatre, the discussion form is right beside the video for your convenience. Please feel free to post any questions or comments so that everyone can contribute to the conversation.

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 
Working with events and properties like GotFocus and LostFocus
Using color constants in Visual Basic
Variable types including String, Date, and Long
Variable naming conventions
Using the Length function to measure string length
Select Case statement as an alternative to If Then
Form Load event and its uses
Changing form properties with VB code
Resizing forms during program execution
Setting form startup position
Adjusting form border style
Tips and tricks for form manipulation
Article 
Welcome to this Visual Basic tutorial where we will explore events and properties, variable types, functions, and some practical coding tips to enhance your applications. Whether you are building forms or working on other projects, understanding these elements will help you create more interactive and user-friendly programs.

Let us begin by looking at events and properties. In Visual Basic, events are actions that occur in the program, such as a form loading, a button being clicked, or a text box receiving focus. For example, the GotFocus event occurs when a control, such as a text box, becomes active and receives user input. Conversely, the LostFocus event occurs when the control loses focus, perhaps after the user clicks away to another field. These events can be used to check or validate user input, or to display helpful messages. To use these, simply double-click the control to open the code window and select the event you want to handle. Here is an example of how you might use these events:

Private Sub txtName_GotFocus()
txtName.BackColor = vbYellow
End Sub

Private Sub txtName_LostFocus()
txtName.BackColor = vbWhite
End Sub

In this example, when the user clicks into the txtName text box, the background color changes to yellow. When the user leaves the control, it changes back to white. The colors here use Visual Basic color constants like vbYellow and vbWhite, but you can use other constants such as vbRed, vbGreen, or even assign RGB values using the RGB function.

Variables are another key concept. Variables store data temporarily while your program is running. You can declare different types of variables, such as String for text, Date for dates and times, and Long for whole numbers. It is important to use meaningful variable names, as this makes your code easier to read and manage. A common convention is to use a prefix that indicates the type, such as str for strings, dat for dates, and lng for long integers. For example:

Dim strCustomerName As String
Dim datOrderDate As Date
Dim lngOrderNumber As Long

Variables allow you to process data and make decisions in your code. For example, if you need to find out how many characters are in a string, you can use the Len function:

Dim strMessage As String
strMessage = "Hello, world!"
MsgBox "The length of the message is " & Len(strMessage)

This will display a message box showing the length of the string.

When you have to make decisions and perform different actions based on different conditions, you often use If...Then statements. However, if you have many possible conditions, it can be easier to use a Select Case statement. Select Case offers a clearer and more organized way to handle multiple values. Here is an example:

Dim intScore As Integer
intScore = 85

Select Case intScore
Case Is >= 90
MsgBox "Grade: A"
Case Is >= 80
MsgBox "Grade: B"
Case Is >= 70
MsgBox "Grade: C"
Case Else
MsgBox "Grade: Below C"
End Select

This code checks the value of intScore and displays the appropriate grade.

Another useful event is the Form Load event, which occurs when your form first opens. Often you will want to set certain properties or initialize values when the form loads. To do this, use the Form_Load procedure. For example, you can change the size of the form, its position, or border style at startup:

Private Sub Form_Load()
Me.Width = 6000
Me.Height = 4000
Me.Top = 1000
Me.Left = 1500
Me.BorderStyle = 3 ' Fixed Dialog
End Sub

In this example, the form is resized and moved to a specific spot when it opens, and its border style is changed.

There are many small but useful tricks you can use to improve your forms. You might want to customize a form's initial position or its appearance before showing it to the user. You can programmatically set the StartUpPosition property or adjust the border style. For example, to center the form on the screen:

Me.StartUpPosition = 2 ' CenterScreen

Experimenting with these properties and events will help you create better user interfaces and more effective programs. Try building some sample projects and test out these techniques for yourself before applying them to your own work. This hands-on practice will help cement your understanding of the concepts and coding methods we have discussed.

If you have any questions while learning, there are communities and discussion forums online where you can discuss Visual Basic topics with other students as well as experts. Engaging with others is a great way to deepen your understanding and solve any issues you might encounter during development. Keep coding and exploring all that Visual Basic has to offer!
Primary Topics 
events, properties, variable types, color constants, naming conventions, string length, form events, Select Case statement
Secondary Topics 
form positioning, border style, tips and tricks
 
 
What's This?

 

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: 10/12/2026 12:06:35 AM. PLT: 0s
Keywords: , Visual Basic 6, VB6 events, GotFocus, LostFocus, Form Load event, color constants, variable types, String, Date, Long, variable naming conventions, Select Case, Length function, form properties, border style, VBLearningZone  PermaLink  How To Use Events Properties Variables and Form Tricks in Visual Basic VBLearningZone Tutorial