Computer Learning Zone CLZ Access Excel Word Windows

You are always a student, never a master. You have to keep moving forward.

-Conrad Hall
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Home > Courses > Visual Basic > VB 6 > 101 > Lesson 03 < Lesson 02 | Lesson 04 >
Object Properties

Lesson 3: Edit Object Captions & Colors


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

In this lesson, we will walk through the basic properties of objects in our Visual Basic project, including how to change the Caption and name properties of buttons and forms. I will show you how to make your form and button labels more user-friendly, adjust background colors, and explain what happens in your code when you rename objects. We will also discuss other properties you can modify and highlight some common issues that occur when renaming buttons, along with how to fix them.

Navigation

Keywords

, Visual Basic properties, change button caption, form caption, rename button, Command button properties, Properties window, Back Color, change form color, Visual Basic design editor, object properties, code window, lost code after rename

 

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 Object Properties
Get notifications when this page is updated
 
Intro In this lesson, we will walk through the basic properties of objects in our Visual Basic project, including how to change the Caption and name properties of buttons and forms. I will show you how to make your form and button labels more user-friendly, adjust background colors, and explain what happens in your code when you rename objects. We will also discuss other properties you can modify and highlight some common issues that occur when renaming buttons, along with how to fix them.
Transcript In this lesson we are going to take a look at some of the properties of the objects we created in the last lesson.

Alright, here we are back in our Project 1. Now when I run this project, I can see I have got Form 1 and Command 1. Not very informative, is it? Maybe it would be nice if I could actually put some stuff on here, like have Form 1 say "First Project" or "First Program," and have our button say something like "Click Me." Command 1 is not very user friendly, is it?

Let's close this. Now to adjust these properties, let's go ahead and close the code window. I will show you how to get back to it in just a minute. Let's close the code window. Now we are back to our Form window. Here is the form and here is the button. Let's start with the button. Click once on the button. Just click once on it.

Notice how you get these little dashes and dots around it. Now these dots are used to resize the button. If you have taken my Word 101 or Excel 101 courses, you know how to resize these objects. We can also move this button by clicking on it and dragging it. Click on it and drag it to move it, or click on the little buttons here to resize it.

If you look over here on the right, you will see the Properties window. Right now since we have Command 1 selected or highlighted, it says the properties for Command 1. Now the name of this button is Command 1. There are a whole bunch of properties in here. We are not going to talk about all of them today.

But the one I want you to look for is Caption. Caption is what actually shows up on the button, and it does not necessarily have to be the button's name. This is just one of the properties for the Command button. Click right here on the Caption and change this to "Click Me" and notice the caption on the button changes as well.

The button will say whatever you put in the Caption property. That is how the Caption property works. Now let's go ahead and run our program. I will click on the Start button and look at that. I changed the button so it says "Click Me" instead of "Command 1." If you click on it, it will generate the Hello World. But we have changed one of the button's properties. Let's go ahead and close the program.

Now what about the form itself? Click right up here on the form where it says Form 1. Notice we now have the properties for Form 1. Remember, almost every object in a Visual Basic program has its own properties.

A button has its own set of properties. There they are. The form has its own set of properties. There they are. Now we can come down here and click on the Caption for the form and make this say "My First Program" for example. Let's run our program now.

And there we go. It is a little more user-friendly. Notice it says "My First Program" across the title bar. That is the Caption property for the form. Let's close our program again.

Now there are many other properties for Command buttons and forms. One of the other properties, for example, is Back Color. Click over here, see this little gray box, click over here, and now you will see a little drop down. Click on the drop down and it will open up a list of colors.

Select this Palette tab over here and you will actually get a color palette. You can click on one of these different colors. I will pick this light blue. There we go. Notice I have changed the background color for the form. If you scroll down this list here, you will see all kinds of different properties.

There is Enabled, Font, ForeColor, Icon. We will talk about most of these in our future classes. But for today, we are just going to stick with some of the basics.

Now one of the other properties you can change is the name of the object itself. For example, if I click on my Command 1 button here, I can actually change the name of this button from Command 1 to something else.

Let's change this button's name to HelloButton. Now, I like to end all of my button names in "Button." Sometimes you see BTNHello. Some programmers like to start off button names with BTN.

Personally, I do not do that. I like to say HelloButton. That is just my style. Feel free to develop your own, but stay consistent.

Now let's go ahead and run our program again. Notice our button says "Click Me." I will click on it. And wait a minute. Something is not right. Our button is not working anymore. We just broke our button.

Let's close our program and see if we can figure out what happened. Here we are back in the Visual Basic Design Editor. There is our button, our HelloButton. Let's double click on the button and check its programming code.

Okay, I double clicked and now Visual Basic put me down here in a new Private Sub. It says Private Sub HelloButton_Click. What is going on?

Well, you have to be careful if you change the name of an object. We changed the name of the button. We renamed it from Command 1 to HelloButton. When you do that, any programming code that happens to be in that object is lost. It is still there, as you can see, but Visual Basic loses track of it.

I like to show this to my beginner students because it always comes up in my classroom-based classes. People always rename their buttons and then wonder why they do not work. So if you rename your button, that is going to happen. All you have to do is take this code up here, cut it out, snip, and then paste it down here.

I will enter to give you some room and I will paste it in. There we go. We can delete these extra lines of code by simply highlighting them and hitting Delete on our keyboard. And there they go.

So just keep in mind, if you change the name of your button, you have to go in here and change your code too.

So now we have made our first program and we have learned how to change some of the properties of the different objects in our program: our Command button and our form's properties.
Quiz Q1. What property determines the text displayed on a Command button in Visual Basic?
A. Caption
B. Name
C. Font
D. Value

Q2. What happens when you change the Name property of a Command button in your Visual Basic project?
A. The code for the button may no longer work until you update the event handler.
B. The button disappears from the form.
C. The button turns red.
D. The project cannot be run anymore.

Q3. Which property do you change to modify the color behind the form?
A. Back Color
B. Caption
C. Enabled
D. ForeColor

Q4. How do you move a Command button on the form?
A. Select it and drag it with the mouse
B. Edit its Back Color property
C. Change its Caption property
D. Double-click it

Q5. What is the effect of changing the Caption property of a form?
A. It changes the text in the title bar of the window.
B. It changes the color of the form.
C. It changes the button text.
D. It changes the position of the form.

Q6. If you accidentally delete the code that makes a button work after renaming it, what should you do?
A. Copy and paste the old code into the new event handler
B. Reinstall Visual Basic
C. Ignore it and continue
D. Rename the button back to its original name

Q7. Where can you find and modify the properties of a selected object in a Visual Basic project?
A. Properties window
B. Solution Explorer
C. Toolbox
D. Output window

Q8. Which statement about the Name property of controls is correct?
A. It is used to identify the control in code but does not affect what users see.
B. It changes the text on the control itself.
C. It always appears in the title bar.
D. It decides the background color of the control.

Q9. What usually happens when you double-click a Command button in the form designer?
A. Visual Basic opens the code window for that button's Click event.
B. The button resizes automatically.
C. The form closes.
D. The button changes color.

Q10. What is a good naming convention for Command buttons, as mentioned in the video?
A. End the name with 'Button', such as HelloButton
B. Start with 'BTN'
C. Only use numbers
D. Use spaces in the names

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 Access Learning Zone is all about exploring some of the fundamental properties of the objects we created last time in our Visual Basic project.

When I load up our Project 1, the first thing I notice is that the form displays "Form 1" and the button simply says "Command 1." This does not give the user much information about what the application does. It would be much better if the form had a title like "First Project" or "First Program," and if the button was labeled with something more meaningful, such as "Click Me." "Command 1" is a default name that is not very helpful for users.

To make these improvements, I first close the code window and return to the Form window, where I can see both the form and the button. If I select the button by clicking on it, small dots appear around it. These can be used to resize the button, just like resizing objects in Word or Excel. Dragging the button allows me to reposition it on the form as needed.

On the right side of the screen, you'll find the Properties window, which displays a long list of configurable settings for the selected object. With the button highlighted, these are the properties for "Command 1." We will not go through all of them today, but I want to direct your attention to the Caption property. The Caption property is what determines the text that appears on the button. By changing the Caption from "Command 1" to "Click Me," the button updates instantly to display the new label.

Now, if I run the program, the button reads "Click Me" instead of the default text. Clicking the button still triggers whatever code we have assigned, but now the interface looks a bit more user-friendly.

Next, let's address the form's properties. When I click on the form, the Properties window updates to show the form's settings instead of the button's. Just as each button has its own set of properties, forms do as well. By modifying the form's Caption property, I can replace "Form 1" with something like "My First Program." Running the application again, you will see that this new title appears in the window's title bar, making the interface much clearer for end users.

Beyond the Caption property, there are many other useful settings for buttons and forms. For example, you can change the background color of the form by modifying the Back Color property. Using the dropdown next to Back Color, you can select from a palette of colors; choosing a light blue can make your form more visually appealing. Scrolling through the Properties window, you'll also notice settings like Enabled, Font, ForeColor, Icon, and many others. We will get to these in future lessons, but for now, I'm focusing on the basics.

Another helpful practice is to assign a meaningful name to your objects. For instance, you might want to rename "Command 1" to something like "HelloButton." Personally, I prefer to use descriptive names that end with the word "Button," such as "HelloButton," rather than abbreviations like "BTNHello." The important thing is to be consistent in your naming convention.

However, if you change the name of a button, you need to be aware of how this affects your code. After renaming "Command 1" to "HelloButton," you may notice that the button no longer works as expected. This happens because Visual Basic generates new code when you rename the control, and any existing event-handling code is left behind and is not automatically reassigned to the newly named object. This is a common situation for beginners.

To fix this, you have to go into the code window and move your original code from the old "Command1_Click" event procedure to the new "HelloButton_Click" event. It is a simple copy and paste. After doing that and cleaning up any extra lines, your button will work correctly again.

In summary, today we made our first project more user-friendly by changing the properties of both the button and the form, including their captions, names, and backgrounds. Understanding how these properties work is a key part of creating professional and user-friendly applications.

If you want a step-by-step video tutorial that walks through all these details, you can find it on my website at the link below.

Live long and prosper, my friends.
Topic List Running a Visual Basic project to view default object properties
Changing the Caption property of a Command button
Modifying the Caption property of a form
Resizing and moving buttons in the form window
Using the Properties window to edit object properties
Setting background color (BackColor) of a form
Changing the Name property of a Command button
Understanding the impact of renaming controls on code
Transferring button click code after renaming a control
Basic navigation between code and design windows in Visual Basic
Article In this lesson, you will learn how to work with some of the properties of objects in Visual Basic, specifically the Form and the Command button that you created in your first project. When you first run your project, you might notice that the default names like "Form1" and "Command1" are not very descriptive for users. It is much better to have these display something meaningful like "First Project" on the form and "Click Me" on the button. To make these changes, begin by closing any open code window so you are looking at the form designer where you can see your form and your button.

Click once on the button to select it. You will see small dots around it, which let you know it is selected. These dots can be used to resize the button by dragging them, and you can move the button by clicking and dragging it to a new location on the form. With the button selected, look to the Properties window, usually located on the right, where you see the properties for the selected object. Since the button is selected, it will say "Command1" at the top. There are many properties listed, but for now, locate the property called Caption. This property controls what text appears on the button itself. Click into the Caption property and change the text from "Command1" to "Click Me." As soon as you do this, you will see the text on the button update in the form designer.

Now, run your project and look at your form. The button will now say "Click Me" instead of the default text. If you have already coded the button, clicking it will trigger the code as before, but the text is now more user-friendly. Close the running program and return to the designer.

Next, you can do the same for the form itself. Click on the form, away from the button, and you will see the Properties window update to show the properties for "Form1." Just like the button, the form has many properties. Find the Caption property for the form. Change it from "Form1" to something more descriptive, like "My First Program." When you run the program now, you will see that the title bar at the top of the window displays "My First Program," making your application more welcoming and easier to identify.

There are many other properties you can explore for forms and buttons. For example, you can change the background color of your form. In the Properties window, look for the BackColor property. Click the drop-down arrow next to it, and you will see a color selection box. Choose the Palette tab to access more color options. Select a color, such as light blue, and the background color of the form will update immediately. Scrolling through the Properties list, you will notice other settings like Enabled, Font, ForeColor, and Icon, which control various aspects of appearance and behavior.

You can also change the actual name of the object itself, not just its Caption. For example, with your button selected, find the Name property in the Properties window. By default, this is "Command1." Change this to something more descriptive, such as "HelloButton." It is a good idea to adopt a naming convention. Some programmers use names like "BTNHello," but you might prefer "HelloButton" or something consistent that makes sense to you.

However, be aware that changing the name of a button after you have written code for it requires an extra step. If you double-click the button after renaming it, you will be taken to a new code section called Private Sub HelloButton_Click. If you previously wrote code in Private Sub Command1_Click, you will notice your code did not move over automatically. It is still in the old code section, so the button no longer works as expected. To fix this, simply copy the existing code from the old section and paste it into the new HelloButton_Click section. You can delete any empty or extra subroutines left behind.

For example, if your button's click event previously looked like this:

Private Sub Command1_Click()
MsgBox "Hello World"
End Sub

And after renaming, Visual Basic gives you this:

Private Sub HelloButton_Click()

End Sub

Copy the code MsgBox "Hello World" from Command1_Click and paste it into HelloButton_Click:

Private Sub HelloButton_Click()
MsgBox "Hello World"
End Sub

Now your button will work with its new name. Remember to keep your code sections organized and always update the code if you change the names of your objects.

By experimenting with these properties, you can make your programs look much more polished and user-friendly. You have seen how to update Captions, change object names, and modify other properties like colors. As you work on future projects, get comfortable exploring the Properties window to see what customizations are available for each object. This foundation will make your applications look and behave the way you want them to.
 
 
 

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: 6/30/2026 8:54:09 AM. PLT: 1s
Keywords: , Visual Basic properties, change button caption, form caption, rename button, Command button properties, Properties window, Back Color, change form color, Visual Basic design editor, object properties, code window, lost code after rename  PermaLink  How To Change Object Properties Like Captions and Colors in Visual Basic Projects