You are on page 1of 80

UNIT 2

BUILDING WINDOWS
APPLICATIONS
Methods
 A method is an action that an object can perform.
For example, Add is a method of the ComboBox
object, because it adds a new entry to a combo
box.
 The following procedure uses the Add method to
add a new item to a ComboBox.

Sub AddEntry(newEntry as String)


Combo1.Add newEntry
End Sub
Properties
 A property is an attribute of an object that defines one of the
object's characteristics, such as size, color, or screen
location, or an aspect of its behavior, such as whether it is
enabled or visible. To change the characteristics of an
object, you change the values of its properties.
 To set the value of a property, follow the reference to an
object with a period, the property name, an equal sign (=),
and the new property value. For example, the following
procedure changes the caption of a Visual Basic form by
setting the Caption property.

Sub ChangeName(newTitle)
myForm.Caption = newTitle
End Sub
Events
 An event is an action recognized by an object,
such as clicking the mouse or pressing a key, and
for which you can write code to respond.
 Events can occur as a result of a user action or
program code, or they can be triggered by the
system.
 Most common events are: click, keydown,
keypress, mousemove, mouseclick etc.
EVENT HANDLING
 Events are basically a user action like key press, clicks, mouse
movements, etc., or some occurrence like system generated
notifications. Applications need to respond to events when they
occur.
 Clicking on a button, or entering some text in a text box, or
clicking on a menu item, all are examples of events. An event
is an action that calls a function or may cause another event.
Event handlers are functions that tell how to respond to an
event.
 VB.Net is an event-driven language. There are mainly two
types of events −

 Mouse events
 Keyboard events
 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
 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
 Handling Keyboard Events
 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

 The event handlers of the KeyDown and KeyUp events get an argument
of type KeyEventArgs. This object has the following 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
 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
WORKING WITH FORMS
Form Properties
S.N Properties Description
1 AutoScale This Boolean property determines whether the controls you place
on the form are automatically scaled to the height of the current
font.
2 AutoScroll This Boolean property indicates whether scroll bars will be
automatically attached to the form if it is resized to a point that not
all its controls are visible.
3 BackColor Sets the form background color.

4 BorderStyle The BorderStyle property determines the style of the form's


border and the appearance of the form:
 None,Sizable,Fixed3D,FixedDialog,FixedSingle,FixedTool
Window,SizableToolWindow
5 Enabled If True, allows the form to respond to mouse and keyboard events;
if False, disables form.
6 Font This property specify font type, style, size

7 Name This is the actual name of the form.

8 Text The text, which will appear at the title bar of the form.

9 Width This is the width of the form in pixel.


Form Events
S.N Event Description

1 Click Occurs when the form is clicked.

2 DoubleClick Occurs when the form control is double-clicked.

3 GotFocus Occurs when the form control receives focus.

4 KeyDown Occurs when a key is pressed while the form has focus.

5 KeyPress Occurs when a key is pressed while the form has focus.

6 KeyUp Occurs when a key is released while the form has focus.

7 LostFocus Occurs when the form loses focus.

8 MouseDown Occurs when the mouse pointer is over the form and a
mouse button is pressed.
9 MouseEnter Occurs when the mouse pointer enters the form.

10 MouseMove Occurs when the mouse pointer is moved over the form.

11 MouseUp Occurs when the mouse pointer is over the form and a
mouse button is released.
TEXTBOX
Properties of the TextBox Control
S.N Property Description

1 Font Gets or sets the font of the text displayed by the control.

2 ForeColor Gets or sets the foreground color of the control.

3 Multiline Gets or sets a value indicating whether this is a multiline TextBox


control.
4 PasswordChar Gets or sets the character used to mask characters of a password in a
single-line TextBox control.
5 ReadOnly Gets or sets a value indicating whether text in the text box is read-
only.
6 ScrollBars Gets or sets which scroll bars should appear in a multiline TextBox
control. This property has values:
 None * Horizontal
 Vertical * Both
7 Text Gets or sets the current text in the TextBox.

8 TextAlign Gets or sets how text is aligned in a TextBox control. This property
has values: Left, Right and Center
9 Name Name of textbox control.
Events of the TextBox Control
S.N Event Description
1 Click Occurs when the control is clicked.
2 DoubleClick Occurs when the control is double-clicked.
3 KeyDown Occurs when a key is pressed while the
textbox has focus.
4 KeyPress Occurs when a key is pressed while the
textbox has focus.
5 KeyUp Occurs when a key is released while the
textbox has focus.
6 LostFocus Occurs when the textbox loses focus.
LABEL
Properties of the Label Control

S.N Property Description


1 Name Name of the Label Control
2 BorderStyle Gets or sets the border style for the control.
3 Font Gets or sets the font of the text displayed by the
control.
4 ForeColor Gets or sets the foreground color of the control.
5 Text Gets or sets the text associated with this control.
6 TextAlign Gets or sets the alignment of text in the label.
Events of the Label Control
S.N Event Description
1 Click Occurs when the control is clicked.
2 DoubleClick Occurs when the control is double-clicked.
3 GotFocus Occurs when the control receives focus.
4 Leave Occurs when the input focus leaves the control.
5 LostFocus Occurs when the control loses focus.
6 TextChanged Occurs when the Text property value changes.
BUTTON
Properties of the Button Control
S.N Property Description
1 Enabled If True, allows the form to respond to mouse and
keyboard events; if False, disables form.
2 BackColor Gets or sets the background color of the control.
3 ForeColor Gets or sets the foreground color of the control.
4 Image Gets or sets the image that is displayed on a button
control.
5 TabIndex Gets or sets the tab order of the control within its
container.
6 Text Gets or sets the text associated with this control.
7 Name Name of the Button Control
Events of the Button Control
S.N Event Description
1 Click Occurs when the control is clicked.
2 DoubleClick Occurs when the user double-clicks the Button
control.
3 GotFocus Occurs when the control receives focus.
4 MouseMove Occurs when the mouse pointer is moved over
the control.
5 MouseUp Occurs when the mouse pointer is over the
control and a mouse button is released.
LISTBOX
Properties of the ListBox Control
S.N Property Description
1 Name This is the actual name of the control.
2 Items Gets the items of the list box.
3 MultiColumn Gets or sets a value indicating whether the list box
supports multiple columns.
4 SelectedIndex Gets or sets the zero-based index of the currently
selected item in a list box.
5 SelectedItem Gets or sets the currently selected item in the list
box.
6 size This is the size (heightxwidth) of the control in
pixel.
7 visible If true, the control is visible at runtime, if false the
control hides or invisible.
Events of the ListBox Control

S.N Event Description


1 Click Occurs when a list box is selected.
SelectedIndexChange Occurs when the SelectedIndex property of a
2
d list box is changed.
3 DoubleClick Occurs when the control is double-clicked.

4 GotFocus Occurs when the control receives focus.

5 LostFocus Occurs when the control loses focus.


COMBOBOX
Properties of the ComboBox Control
S.N Property Description
1 Enabled If True, allows the control to respond to mouse
and keyboard events; if False, disables control.
2 Font This property specify font type, style, size
3 Name This is the actual name of the control.
4 Items Gets an object representing the collection of the
items contained in this ComboBox.
5 MaxLength Gets or sets the maximum number of characters a
user can enter in the editable area of the combo
box.
6 SelectedIndex Gets or sets the index specifying the currently
selected item.
7 SelectedItem Gets or sets currently selected item in the
ComboBox.
Events of the ComboBox Control
S.N Event Description
1 SelectedIndexChang Occurs when the SelectedIndex property of a
ed ComboBox control has changed.
2 Click Occurs when the control is clicked.
3 DoubleClick Occurs when the control is double-clicked.
4 GotFocus Occurs when the control receives focus.
5 KeyDown Occurs when a key is pressed while the control
has focus.
6 KeyPress Occurs when a key is pressed while the control
has focus.
CHECKBOX
Properties of the CheckBox Control
S.N Property Description
1 Font This property specify font type, style, size
2 Name This is the actual name of the control.
3 CheckAlign Gets or sets the horizontal and vertical alignment of
the check mark on the check box.
4 Checked Gets or sets a value indicating whether the check box
is selected.
5 Text Gets or sets the caption of a check box.
Events of the CheckBox Control
S.N Event Description
1 Click Occurs when the control is clicked.
2 DoubleClick Occurs when the control is double-clicked.
3 GotFocus Occurs when the control receives focus.
4 KeyDown Occurs when a key is pressed while the control has
focus.
5 KeyPress Occurs when a key is pressed while the control has
focus.
PICTUREBOX
Properties of the PictureBox Control
S.N Property Description

1 ErrorImage Gets or specifies an image to be displayed when an error


occurs during the image-loading process .
2 Image Gets or sets the image that is displayed in the control.

3 ImageLocation Gets or sets the path or the URL for the image displayed in
the control.
4 SizeMode Determines the size of the image to be displayed in the
control. This property takes its value from the
PictureBoxSizeMode enumeration, which has values:
 Normal, StrechImage, AutoSize, CenterImage, Zoom.
5 Name This is the actual name of the control.

6 Text Gets or sets the text for the picture box.

7 Visible If true, the control is visible at runtime, if false the control


hides or invisible.
8 Enabled If True, allows the control to respond to mouse and
keyboard events; if False, disables control.
Events of the PictureBox Control
S.N Event Description

1 Click Occurs when the control is clicked.

2 DoubleClick Occurs when the control is double-clicked.

3 FontChanged Occurs when the value of the Font property changes.

4 ForeColorChanged Occurs when the value of the ForeColor property


changes.
5 KeyPress Occurs when a key is pressed when the control has
focus.
6 KeyUp Occurs when a key is released when the control has
focus.
RADIOBUTTON
Properties of the RadioButton Control
S.N Property Description
1 Checked Gets or sets a value indicating whether the
control is checked.
2 Text Gets or sets the caption for a radio button.
3 Name This is the actual name of the control.
4 Visible If true, the control is visible at runtime, if false
the control hides or invisible.
5 Enabled If True, allows the control to respond to mouse
and keyboard events; if False, disables control.
6 Font This property specify font type, style, size
Events of the RadioButton Control
S.N Event Description
1 CheckedChanged Occurs when the value of the Checked property
of the RadioButton control is changed.
2 Click Occurs when the control is clicked.
3 DoubleClick Occurs when the control is double-clicked.
4 GotFocus Occurs when the control receives focus.
5 KeyDown Occurs when a key is pressed while the control
has focus.
6 KeyPress Occurs when a key is pressed while the control
has focus.
PANEL
SN Name Description
1 BackColor Gets or sets the background color for the control.

2 Enabled Gets or sets a value indicating whether the control


can respond to user interaction.
3 Font Gets or sets the font of the text displayed by the
control.
4 ForeColor Gets or sets the foreground color of the control.

5 Name Gets or sets the name of the control.

6 Size Gets or sets the height and width of the control.

7 Text Gets or sets the text of the control

8 Visible Gets or sets a value indicating whether the control


and all its child controls are displayed.
Events of Panels
SN Name Description
1 Click Occurs when the control is clicked.

2 DoubleClick Occurs when the control is double-clicked.

3 DragDrop Occurs when a drag-and-drop operation is completed.

4 KeyPress Occurs when any key is pressed

5 KeyUp Occurs when any key is released

6 LostFocus Occurs when the control loses focus.

7 MouseDown Occurs when the mouse pointer is over the control and a
mouse button is pressed.

8 MouseMove Occurs when the mouse pointer is moved over the control.

9 MouseUp Occurs when the mouse pointer is over the control and a
mouse button is released.
TIMER
Properties of Timer
SN Name Description
1 Name This is the actual name of the control.
2 Enabled Gets or sets a value indicating whether the Timer should raise
the Elapsed event.
3 Interval Gets or sets the interval, expressed in milliseconds, at which to
raise the Elapsed event.
4 Modifier Indicates the visibility level of the object

5 Tag User Defined data associated with the object


Events of Timer

SN Name Description
1 Disposed Occurs when the component is disposed by a call to the
Dispose method.
2 Tick Occurs when the timer’s time change.
LISTVIEW
Properties of the ListView Control
S.N Property Description

1 Alignment Gets or sets the alignment of items in the control.

2 BackColor Gets or sets the background color.

3 Columns Gets the collection of all column headers that appear in the
control.
4 Name This is the actual name of the control.

5 Visible If true, the control is visible at runtime, if false the control


hides or invisible.
6 Enabled If True, allows the control to respond to mouse and keyboard
events; if False, disables control.
7 SelectedItems Gets the items that are selected in the control.

8 ShowGroups Gets or sets a value indicating whether items are displayed in


groups.
9 View Gets or sets how items are displayed in the control. This
property has the following values:
 LargeIcon, SmallIcon, List, Details, Tile
Events of the ListView Control
S.N Event Description
1 Click Occurs when the control is clicked.
2 DoubleClick Occurs when the control is double-clicked.
3 GotFocus Occurs when the control receives focus.
4 KeyDown Occurs when a key is pressed while the control has
focus.
5 KeyPress Occurs when a key is pressed while the control has
focus.
6 KeyUp Occurs when a key is released while the control has
focus.
TREEVIEW
Properties of the TreeView Control
S.N Property Description

1 BackColor Gets or sets the background color for the control.

2 BackgroundImage Gets or set the background image for the TreeView


control.
3 Font Gets or sets the font of the text displayed by the control.

4 ForeColor The current foreground color for this control, which is


the color the control uses to draw its text.
6 Nodes Gets the collection of tree nodes that are assigned to the
tree view control.
7 Text Gets or sets the text of the TreeView.

8 Name This is the actual name of the control.

9 Visible If true, the control is visible at runtime, if false the


control hides or invisible.
Events of the TreeView Control
S.N Event Description

1 AfterCollapse Occurs after the tree node is collapsed.

2 AfterExpand Occurs after the tree node is expanded.

3 AfterSelect Occurs after the tree node is selected.

4 BeforeCollapse Occurs before the tree node is collapsed.

5 BeforeExpand Occurs before the tree node is expanded.

6 BeforeLabelEdit Occurs before the tree node label text is edited.

7 BeforeSelect Occurs before the tree node is selected.

8 ItemDrag Occurs when the user begins dragging a node.

9 NodeMouseClick Occurs when the user clicks a TreeNode with the


mouse.
10 NodeMouseDoubleCli Occurs when the user double-clicks a TreeNode with
ck the mouse.
DATE TIME PICKER
Properties
Sl.N Property Description
o.
1 BackColor Gets or sets a value indicating the background color of
the DateTimePicker control.
2 ForeColor Gets or sets the foreground color of the DateTimePicker
control.
3 Format Gets or sets the format of the date and time displayed in
the control.
4 MaxDate Gets or sets the maximum date and time that can be
selected in the control.
5 MinDate Gets or sets the minimum date and time that can be
selected in the control.
6 Text Gets or sets the text associated with this control
.
7 Value Gets or sets the date/time value assigned to the control.
Events
Sr.No Event Description
.
1 Click Occurs when the control is clicked.
2 DoubleClick Occurs when the control is double-clicked.
3 DragDrop Occurs when a drag-and-drop operation is
completed.
4 FormatChanged Occurs when the Format property value has
changed.
5 MouseClick Occurs when the control is clicked with the mouse.
6 MouseDoubleCli Occurs when the control is double-clicked with the
ck mouse.
7 TextChanged Occurs when the value of the Text property
changes.
8 ValueChanged Occurs when the Value property changes.
LINK LABEL
Properties
Sl. No Properties Description

1 TextAlign Text alignment is set using this property either to


right or left by giving values 0 or 1
2 Text Property used for the label text.
3 Name This is the actual name of the control.
4 Visible If true, the control is visible at runtime, if false the
control hides or invisible.
5 ActiveLinkColo Property used to specify the color of the active
r link.
6 DisabledLinkCol Property used to specify the color of the disabled
or link.
7 LinkColor Property is used to specify the color for a normal
link.
8 VisitedLinkColo Property is used to specify the color for a visited
r link.
Events
Sl No Events Description
1 LinkClicked Triggered when the link is clicked.
2 DoubleClick Occurs when the control is double clicked
3 GotFocus Occurs when the control receives focus.
4 KeyDown Occurs when a key is pressed while the control has
focus.
5 KeyPress Occurs when a key is pressed while the control has
focus.
6 KeyUp Occurs when a key is released while the control has
focus.
7 LostFocus Occurs when the control loses focus.
DIALOG BOXES
OPENFILE DIALOG
Properties of the OpenFileDialog
Control
S.N Property Description
1 Name Indicates the name of the control
2 Title Indicates the title of the dialog box
3 FileName Gets or sets a string containing the file name
selected in the file dialog box.
4 InitialDirectory Gets or sets the initial directory displayed by the
file dialog box.
5 Multiselect Gets or sets a value indicating whether the dialog
box allows multiple files to be selected.
6 ShowHelp Gets or sets a value indicating whether the Help
button is displayed in the file dialog box.
Methods of the OpenFileDialog
Control
S.N Method Name Description
1 OpenFile Opens the file selected by the user, with
read-only permission. The file is specified
by the FileName property.
2 Reset Resets all options to their default value.
SAVEFILE DIALOG
Properties of the SaveFileDialog
Control
S.N Property Description
1 Name Indicates the name of the control
2 DefaultExt Gets or sets the default file name extension.
3 FileName Gets or sets a string containing the file name
selected in the file dialog box.
4 FileNames Gets the file names of all selected files in the dialog
box.
5 InitialDirector Gets or sets the initial directory displayed by the file
y dialog box.
6 ShowHelp Gets or sets a value indicating whether the Help
button is displayed in the file dialog box.
7 Title Gets or sets the file dialog box title.
Methods of the SaveFileDialog
Control
S.N Method Name Description
1 OpenFile Opens the file with read/write permission.

2 Reset Resets all dialog box options to their default values.


FONTDIALOG
Properties of the FontDialog
Control
S. Property Description
N
1 Name Indicates the name of the control
2 Color Gets or sets the selected font color.
3 Font Gets or sets the selected font.
4 MaxSize Gets or sets the maximum point size a user can select.
5 MinSize Gets or sets the minimum point size a user can select.
6 ShowApply Gets or sets a value indicating whether the dialog box
contains an Apply button.
7 ShowColor Gets or sets a value indicating whether the dialog box
displays the color choice.
Methods of the FontDialog Control
S.N Method Name Description
1 Reset Resets all options to their default values.

2 RunDialog When overridden in a derived class, specifies a


common dialog box.
3 ShowDialog Runs a common dialog box with a default owner.
COLORDIALOG
Properties of the ColorDialog
Control
S.N Property Description
1 Name Indicates the name of the control
2 Color Gets or sets the color selected by the user.
3 CustomColor Gets or sets the set of custom colors shown in the
s dialog box.
4 ShowHelp Gets or sets a value indicating whether a Help button
appears in the color dialog box.
5 SolidColorOn Gets or sets a value indicating whether the dialog box
ly will restrict users to selecting solid colors only.
Methods of the ColorDialog
Control
S.N Method Name Description

1 Reset Resets all options to their default values, the last


selected color to black, and the custom colors to
their default values.
2 RunDialog When overridden in a derived class, specifies a
common dialog box.
3 ShowDialog Runs a common dialog box with a default owner.
PRINTDIALOG
Properties of the PrintDialog
Control
S.N Property Description
1 AllowCurrentPa Gets or sets a value indicating whether the Current
ge Page option button is displayed.
2 AllowPrintToFil Gets or sets a value indicating whether the Print to
e file check box is enabled.
3 AllowSelection Gets or sets a value indicating whether
the Selectionoption button is enabled.
4 PrinterSettings Gets or sets the printer settings the dialog box
modifies.
5 PrintToFile Gets or sets a value indicating whether the Print to
file check box is selected.
6 Name Indicates the name of the control
Methods of the PrintDialog
Control
S.N Method Name Description
1 Reset Resets all options to their default values.

2 RunDialog When overridden in a derived class, specifies a


common dialog box.
3 ShowDialog Runs a common dialog box with a default owner.
DESIGNING MENUS :
MENU STRIP
Properties of MenuStrip:
S.N Properties Description
1 Name This is the actual name of the menu.
2 Text The text, which will be display in the menu.
3 Items Collection of items or menu can be added,
delete and modify
4 Font This property specify font type, style, size
5 Image Display a small icon for menu
6 Shortcutkey Used to create shortcut for the menu.
7 Size Size of the menu in pixel.
8 Visible Determin whether the item is visible or not
Events of MenuStrip:
S.N Event Description
1 Click Occurs when the menu is clicked.
2 DoubleClick Occurs when the menu control is double-clicked.
3 GotFocus Occurs when the menu control receives focus.
4 LostFocus Occurs when the menu loses focus.
5 MouseDown Occurs when the mouse pointer is over the menu
and a mouse button is pressed.
6 MouseEnter Occurs when the mouse pointer enters the menu.
7 MouseMove Occurs when the mouse pointer is moved over the
menu.
8 MouseUp Occurs when the mouse pointer is over the menu
and a mouse button is released.
CREATING MENUS
 1. Start Visual Studio 2010 and click File ➪ New Project. In the
New Project dialog, select Windows Forms Application in the
Templates pane and enter the project name Windows Forms Menus
in the Name field. Click the OK button to have the project created.
 2. Click the form in the Forms Designer and set the properties of the
form as desire.
 3. Drag a MenuStrip control from the Toolbox and drop it on your
form. It is automatically
 positioned at the top of your form.
 4. Click the MenuStrip control on top of the form, a textbox will
appear, type the menu name, another two textbox (right and bottom)
will appear automatically. Now you can create menu and sub menu
according to your requirements.
 5. In the Properties window, you can manipulate each menu property
such as name, alignment, font, enable, image, shortcut key etc.
 6. On double clicking each menu, you can create its corresponding
events and write the code correspondingly.
CONTEXTMENU
Properties of ContextMenuStrip:
S.N Properties Description
1 Name This is the actual name of the menu.
2 Text The text, which will be display in the menu.
3 Items Collection of items or menu can be added,
delete and modify
4 Font This property specify font type, style, size
5 Image Display a small icon for menu
6 Shortcutkey Used to create shortcut for the menu.
7 Size Size of the menu in pixel.
Visible Determin whether the item is visible or not
Events of ContextMenuStrip:
S.N Event Description
1 Click Occurs when the menu is clicked.
2 DoubleClick Occurs when the menu control is double-clicked.
3 GotFocus Occurs when the menu control receives focus.
4 LostFocus Occurs when the menu loses focus.
5 MouseDown Occurs when the mouse pointer is over the menu
and a mouse button is pressed.
6 MouseEnter Occurs when the mouse pointer enters the menu.
7 MouseMove Occurs when the mouse pointer is moved over the
menu.
8 MouseUp Occurs when the mouse pointer is over the menu
and a mouse button is released.
Creating Context Menus
 1. Go to the Forms Designer in your Windows Forms Menus project and then click the Toolbox to
locate the ContextMenuStrip control. Drag and drop it onto your form, contextmenustrip appear at
the top of the form and an object is added at the bottom of the development environment just as the
MenuStrip control was.
 2. In the Properties window, click the button next to the Items property. You’ll be adding five menu
items in your context menu in the next several steps.
 3. Click the ContextMenuStrip control on top of the form, only one top-level menu can be created
with the ContextMenuStrip control. But you can create submenu items with the ContextMenuStrip if
needed.
 4. Type the first menu name, another two textbox (right and bottom) will appear automatically. Now
you can create menu and sub menu according to your requirements.
 5. In the Properties window, you can manipulate each menu property such as name, alignment, font,
enable, image, shortcut key etc.
 6. On double clicking each menu, you can create its corresponding events and write the code
correspondingly. A context menu can be called using the method “show”.
 7. Now you can add any control on the form and set the contextmenustrip property to the created
contextmenustrip. So, when right clicking on that control, the context menu appears.
ACCESS SHORCUT KEYS
General
Alt + F11 This toggles switch displays the VBE from the application window and vice
versa.
Ctrl + G Displays the Immediate window.
Ctrl + F Opens the Find dialog box.
F3 Finds Next.
Shift + F3 Finds Previous.
Ctrl + H Opens the Replace dialog box.
Ctrl + Z Cancels the last keyboard stroke or the last mouse operation.
F5 Runs the current procedure or continues execution after pausing.
Ctrl + Break Halts a procedure.
Shift + F5 Terminates a procedure and resets all variables to their default values.
Shift + F10 Displays the active window's shortcut menu.
Ctrl + R Opens the Project Explorer.
F4 Opens the Properties window.
F2 Opens the Object Browser.
F1 Opens VBA Help.
F7 Gives focus to the open module window.
Code module
Ctrl + Down Arrow Selects the next procedure.
Ctrl + Up Arrow Selects the previous procedure.
Ctrl + Page Down Shifts one screen down.
Ctrl + Page Up Shifts one screen up.
Ctrl + Shift + F2 Goes to the last position.
Ctrl + Home Goes to the beginning of module. (Also in the Immediate window.)

Ctrl + End Goes to the end of module. (Also in the Immediate window.)
Ctrl + Right Arrow Moves one word to the right.
Ctrl + Left Arrow Moves one word to the left.
End Moves to the end of the line.
Home Moves to the beginning of the line.
Ctrl + Y Deletes the current line.
Ctrl + Delete Deletes to the end of a word.
Ctrl + Shift + F9 Clears all breakpoints.
Project Explorer
F7 Shift + Opens the selected file's module.
Enter
Home Selects the first file in the list.
End Selects the last file in the list.
Right arrow Expands a sublist.
Left arrow Collapses a sublist.
Up arrow Moves up the list one item at a time.
Down arrow Moves down the list one item at a time.
End of slide

You might also like