Showing posts with label Event. Show all posts
Showing posts with label Event. Show all posts

Saturday, November 20, 2010

Visual Basic Forms Event : Activate

Purpose : The Activate event fires when a form, MDI form , or data report becomes the active window in an application.


Syntax :
Sub Form_Activate ( )
Sub MDIForm_Activate ( )
Sub DataReport_Activate ( )



An object can become active by a user action such as clicking the object or by using the Show or SetFocus method in code. The activate event can occur only when an object is visible . A form loaded with the Load statement , for example , isn't visible unless you use the Show method or set the form's Visible property to True. The Activate event occurs only when moving the focus within an application. Moving the focus to or from an object in another application doesn't trigger the event.


The Deactivate Event :
the Deactivate and Activate events have an inverse relationship. Whereas the Activate eent occurs when a form becomes active , the Deactivate event occurs when a form is no longer active. The Deactivate event occurs only when moving the focus within an application. Moving the focus to or from an object in another application doesn't trigger either event. The Deactivate event doesn't occur when unloading an object.
The LostFocus event occurs before the Deactivate event.

Tuesday, October 5, 2010

Visual Basic Date and Time Event : Timer

Purpose : The Timer event contains the actions that take place when a time equal to the interval value of the timer control has elapsed. this event triggers every time the interval of time elapses until the timer control is disabled . A timer control is disabled by setting its Enabled property to False , by setting its Interval property to 0 , or by unloading the form.

Syntax :
Sub Name_Timer ( [ Index As Integer ] )

Name : Name property of the timer
Index : Serves as a reference for the part of a control array

Option Explicit
Dim x%, y%, Radius%
Const pi = 3.14159265

Private Sub Timer1_Timer()
Cls
Static num As Double
FillColor = QBColor(1)
FillStyle = 1
x% = ScaleWidth / 2
y% = ScaleHeight / 2
Radius% = ScaleWidth / 4
Circle (x%, y%), Radius%, num, -6.283
num = num - ((2 * pi) / 60)
Text1.Text = Str$(num)
If Abs(num) >= 6.238 Then
num = 0
Timer1.Enabled = 0
Cls
End If
End Sub