eHow launches Android app: Get the best of eHow on the go.

About

Visual Basic Properties

Contributor
By Darrin Koltow
eHow Contributing Writer
(1 Ratings)

Each programmable control in the Visual Basic toolbox has a set of attributes you can define. These attributes are called properties. You choose selected properties for a control based on how you want it to appear and behave when a user runs your program.

    Button Control

  1. The button control is one of the most recognizable controls in Windows programs. Despite its simple appearance, the button has a slew of properties you can change to suit your program's needs. You can change the order in which the button is highlighted when the user presses the Tab key (TabIndex), completely change the appearance of the button by loading a custom image into it (Image property), or simply change the button's Text with the Text property.
  2. Change Properties in Form Designer

  3. You can change the Text and other properties either in the Visual Basic form design window, or using Visual Basic code. Using the form design window to change object properties involves navigating to View>Designer and single-clicking a control, such as a button control, on your form. With the button now selected, you can use the Properties window to find the Text property and type the new text you want the button to display. The button will show the new text when you're done typing.
  4. Changing Properties in Code

  5. You can also change a control's properties through code. For the button example you might use a line like Button1.Text = "PushMe!". You would use this statement in a subroutine that gets executed as soon as the program starts. The Form1_Load subroutine would be a good candidate for this.
  6. Code is More Efficient for Changing Properties

  7. You might wonder why you would bother with typing code to change properties, when you could use the more visually intuitive form designer. Use code instead of the designer for a number of reasons, one of them being efficiency. If you're changing many control properties to the same value, writing code to do so is much speedier than entering by hand each control's property. For example, disabling each control on a form can be done with the following three lines.

    For Each ct As Control In Me.Controls
    ct.Enabled = False
    Next

    Also, events may occur during your program's execution that require you to change a certain property to one value, and then to another value when another event occurs. There's obviously no way you could change the property during design time to accommodate this run-time situation. Changing the property through code is thus, the only logical choice.
  8. Common Versus Unique Properties

  9. Some properties are common to all or nearly all Visual Basic controls while others are unique to specific controls. The Visible property, for example, exists for each control; you obviously want to have the choice of changing any object's visibility. On the other hand, the LinkBehavior property is found only in the LinkLabel control. You wouldn't expect an option control button to have such a property, as it has nothing inherently to do with a Hypertext link.
Subscribe

Post a Comment

Post a Comment Post this comment to my Facebook Profile

Related Ads

Get Free Computers Newsletters

Copyright © 1999-2009 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy .   en-US Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License. † requires javascript

eHow Computers
eHow_eHow Technology and Electronics