Hi rtc_18m,
Firstly,
VB is a
event-driven programming language., which means that a block of code is executed on occurence of an event.
Now, lets look at the following line:
Private Sub chkItalic_Click()
Sub means this block of code is a
procedure; it is important to note the difference between a
Function and a
Sub, a
Functions returns a value while a
Sub does'nt.
chkItalic is the name of your check-box.
Private means that this procedure is local only to the current form\module, so this procedure can't be used by other forms\modules.
"...
_Click" signifies a click event.
In all, this is
local procedure which is called when someone
clicks on the
chkItalic check-box.
Now since the user has clicked on the check-box and we have entered aforementioned procedure, consider only these lines:
If chkItalic.Value = 1 Then
txtDisplay.FontItalic = True
We now need to find, whether the check-box is checked(ticked) or not. This is the stored in the
property for check-boxes called
Value, below are the possible values of
Value:
0-Unchecked
1-Checked
2-Greyed
We want to change the text in italics, only when the
chkItalic check-box is checked(ticked)
FontItalic is a property for text-boxes, which when
True, changes the text in the tex-box to italics.
Consider:
Else ' If not checked.
txtDisplay.FontItalic = False
This is the code that is executed, if the check-box was unchecked(unticked) at the time of clicking on it. This is the exact opposite of the above set of statements, we need to un-italize the text in the text-box, if the chkItalic check-box is unchecked(unticked).