Page 57 - Open Soource Technologies 304.indd
P. 57

Unit 3: Understanding Controls and Control Events



               Top
               Sets the Y coordinate of the Command Button.

               Use MaskColor
               If set to True, the MaskColor property will be used as the transparent color in the picture used
               on the Command Button. See the MaskColor property for information.
               Visible
               Determines whether the Command Button appears on the Form. I.e. if set to False, the Command
               Button will be unavailable to the user - even by trying to set focus to it with the tab key.
               Width

               Sets the width of the Command Button.
               3.4.4.2 Methods

               Move
               Left As Single, [Top], [Width], [Height]

               This method changes the position and optionally the size of the Command Button. The following
               example will move the Command Button to the top-left of the Form and makes it into a square:
               Command1.Move 0, 0, 375, 375 SetFocus

               Sets the focus to the Command Button. This means that pressing the Enter key will activate the
               Click event, even if another Command Button has it’s Default property set to True.

               3.4.4.3 Events
               Click

               This is probably the most important event for the Command Button. It occurs when the user
               clicks on the Command Button, or activates it in another way  e.g. with the Enter key, Space key,
               Alt+[Underlined Letter] or Escape key depending on the properties of the Command Button.

                 Private Sub Command1_Click()
                 Text3.Text = CStr(Val(Text1.Text) + Val(Text2.Text))

                 End Sub

               GotFocus
               Occurs when the Command Button gets focus either from the Tab key, when it is clicked on by
               the user or by using the SetFocus method.
               KeyDown and KeyUp
               KeyCode As Integer, Shift As Integer

               When the user presses a keyboard key down or releases a key, these events occur.



                                      LOVELY PROFESSIONAL UNIVERSITY                         51
   52   53   54   55   56   57   58   59   60   61   62