The Code

The code that you will create will look like this when you are finished:

code

You will actually type very little. Lines 1, 2, and 5 where provided for you. The cursor is flashing at the start of line 3.
Type "me" then a dot. As soon as you type the dot, a pop-up window appears with a list of everything that could possible follow "me."

pop-upNow, if you type an "L" the list will be narrowed down to only those things that begin with "L".  LblMessage will be highlighted. Now all you have to do is press tab and "LblMessage is added to the line of code.
Type another dot and another pop-up list appears with all of the properties of a label. Select "Text" from the list by typing "T", then pressing tab when Text is highlighted.

You only need to add = "Red" to finish the line of code.

Line 4 is just as easy: type "me." then select backcolor from the pop-up list. Type the equal sign then select a color from another pop-up list.

What the code means: The word me refers to the form. The dot separates an object from a child or a property. Since the label, LblMessage, is on the form, it appears on the list of objects that are on the form and it's properties. The label has its own properties and we have made the text say "Red". On line 4, we change the backColor property of the form to Red. Backcolor can only be assigned a color, so as soon as we type the equal sign the pop-up box contains the values that can be assigned to a color property. The two statements that we have added are called assignment statement: they are used to "assign" a new value. In line 3 we have assigned a new value to LblMessage.text. In line 4 we assign a new value to the backcolor of the form.

Experiment: Run the program and click BtnRed. Add the code for BtnBlue.

 


INDEX, The Code View, Selecting code from list, Events, Arguments, Concatenation, Sender, Scroll Bars, Decimal Values on Scroll Bar, Picture Boxes: the Seasons, Comments, Printing, Closing
Next lesson: Functions in Visual Basic

Copyright © Zebra0.com
All rights reserved worldwide.

 
 

Selecting code from list