From Event to Action: Accelerate Your Decision Making with Real-Time Automation
UNIT4.2(VB).pptx
1. Handling Mouse Events
Mouse events occur with mouse movements in forms
and controls. Following are the various mouse events
related with a Control class −
MouseDown − it occurs when a mouse button is pressed
MouseEnter − it occurs when the mouse pointer enters
the control
MouseHover − it occurs when the mouse pointer hovers
over the control
MouseLeave − it occurs when the mouse pointer leaves
the control
MouseMove − it occurs when the mouse pointer moves
over the control
2. • MouseUp − it occurs when the mouse pointer
is over the control and the mouse button is
released
• MouseWheel − it occurs when the mouse
wheel moves and the control has focus
3. • The MouseEventArgs object is used for handling
mouse events. It has the following properties −
• Buttons − indicates the mouse button pressed
• Clicks − indicates the number of clicks
• Delta − indicates the number of detents the
mouse wheel rotated
• X − indicates the x-coordinate of mouse click
• Y − indicates the y-coordinate of mouse click
4. Handling Keyboard Events
• Following are the various keyboard events
related with a Control class −
• KeyDown − occurs when a key is pressed
down and the control has focus
• KeyPress − occurs when a key is pressed and
the control has focus
• KeyUp − occurs when a key is released while
the control has focus
5. properties −
• Alt − it indicates whether the ALT key is pressed
• Control − it indicates whether the CTRL key is
pressed
• Handled − it indicates whether the event is
handled
• KeyCode − stores the keyboard code for the
event
• KeyData − stores the keyboard data for the event
6. • KeyValue − stores the keyboard value for the
event
• Modifiers − it indicates which modifier keys
(Ctrl, Shift, and/or Alt) are pressed
• Shift − it indicates if the Shift key is pressed
7. Exception Handling
• An exception is a problem that arises during
the execution of a program. An exception is a
response to an exceptional circumstance that
arises while a program is running, such as an
attempt to divide by zero.
• Exceptions provide a way to transfer control
from one part of a program to another. VB.Net
exception handling is built upon four
keywords - Try, Catch, Finally and Throw.
8. • Try − A Try block identifies a block of code for which
particular exceptions will be activated. It's followed by one
or more Catch blocks.
• Catch − A program catches an exception with an exception
handler at the place in a program where you want to handle
the problem. The Catch keyword indicates the catching of
an exception.
• Finally − The Finally block is used to execute a given set of
statements, whether an exception is thrown or not thrown.
For example, if you open a file, it must be closed whether
an exception is raised or not.
• Throw − A program throws an exception when a problem
shows up. This is done using a Throw keyword.
9. Exception Class Description
System.IO.IOException Handles I/O errors.
System.IndexOutOfRangeException Handles errors generated when a method
refers to an array index out of range.
System.ArrayTypeMismatchException Handles errors generated when type is
mismatched with the array type.
System.NullReferenceException Handles errors generated from deferencing
a null object.
System.DivideByZeroException Handles errors generated from dividing a
dividend with zero.
System.InvalidCastException Handles errors generated during
typecasting.
System.OutOfMemoryException Handles errors generated from insufficient
free memory.
System.StackOverflowException Handles errors generated from stack
overflow.