Ppt lesson 03
Upcoming SlideShare
Loading in...5
×
 

Ppt lesson 03

on

  • 1,336 views

 

Statistics

Views

Total Views
1,336
Views on SlideShare
1,226
Embed Views
110

Actions

Likes
0
Downloads
17
Comments
0

3 Embeds 110

http://thsbonovb.wikispaces.com 63
http://thsbono.wikispaces.com 31
http://bodrie.wikispaces.com 16

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Ppt lesson 03 Ppt lesson 03 Presentation Transcript

  • Microsoft Visual Basic 2005 BASICS Lesson 3 Events and Code
  • Objectives
    • Describe events and how events are key to Windows programs.
    • Access the Code window.
    • Add code to a command button.
    • Add a picture to a form.
  • Objectives (cont.)
    • Set picture properties.
    • Use code to set properties.
    • Set the Cancel and Default command button properties.
    • Create a stand-alone Windows program.
  • Events
    • Event-driven system
      • Computer is constantly waiting for the user to take some action
        • With the mouse, keyboard, or other device
    • Action triggers an event
      • Software in the computer attempts to find something to do with that action
  • Events (cont.)
    • When you create an object
      • It is up to you to write the code that will handle the events.
    • Event procedure
      • Code that handles a specific event
  • Accessing the Code Window
    • Add code to a command button
      • Open the form that contains the command button.
      • Double-click the command button.
        • The Code window will appear.
    • Subroutine
      • Section of code to perform a specific task
  • Accessing the Code Window (cont.)
  • Adding Code to a Command Button
    • Add code to the Code window
      • Simply enter the code from the keyboard.
    • You can insert and delete text and use cut, copy, and paste.
    • IntelliSense technology
      • Anticipates what you are about to key
        • Completes your statement for you
    • Visual Basic is not case sensitive.
  • Adding Code to a Command Button (cont.)
  • Adding a Picture to a Form
    • PictureBox control
      • Provides a framework for displaying a picture on a form
  • Adding a Picture to a Form (cont.)
  • Adding a Picture to a Form (cont.)
  • Adding a Picture to a Form (cont.)
  • Adding a Picture to a Form (cont.)
  • Setting Image Properties
    • Image controls
      • Have an extensive set of properties that can be changed
  • The Name Property
    • Name property
      • Names the PictureBox control
    • The pic prefix is often used when naming PictureBox controls.
  • The SizeMode Property
    • SizeMode property
      • Allows you to specify what to do when picture and space available do not match
    • Values
      • Normal
      • Center
      • StretchImage
      • AutoSize
  • The SizeMode Property (cont.)
  • The SizeMode Property (cont.)
  • The Visible Property
    • Visible property
      • Gives you control over when a picture is visible to the user
  • Use Code to Set Properties
    • Change a property by specifying
      • Name of the control
      • Property
      • Value
  • Use Code to Set Properties (cont.)
    • The item to the right of the dot is called a method.
    • In object-oriented programming
      • You do not actually set the property.
      • You ask an object to set its own property by sending it a message.
  • Use Code to Set Properties (cont.)
  • Use Code to Set Properties (cont.)
  • Adding Access Keys to Command Buttons
    • Access key
      • Declared in the Text property in Visual Basic programs
      • Allows a user to activate a command without using a mouse
  • Setting the AcceptButton and CancelButton Form Properties
    • AcceptButton property
      • Names the command button to be used when the user presses the Enter key
    • CancelButton property
      • Names the command button to be used when the user presses the Esc key
  • Summary
    • Windows is an event-driven environment. In an event-driven system, the user triggers events that control the work.
    • To control what happens when an event occurs, you must write event procedures for each event that you want to handle.
    • To access the Code window, double-click an object, such as a command button.
  • Summary (cont.)
    • Visual Basic code is written in sections called subroutines.
    • Adding code is much like working in a word processor. The basic text-editing features are available. In addition, Visual Studio 2005 has IntelliSense features to help format your program code.
  • Summary (cont.)
    • The End statement ends a program.
    • The PictureBox tool allows you to add a PictureBox control to a form.
    • Using the (Name) property, you can give a PictureBox control a name. That name will be used when you refer to the control in code.
  • Summary (cont.)
    • Setting the SizeMode property to StretchImage causes a picture to resize to fit the dimensions of the PictureBox control. Setting the SizeMode property to AutoSize causes a PictureBox control to resize to fit the picture loaded into it.
    • The Visible property controls whether an object is shown or hidden.
  • Summary (cont.)
    • Setting properties in code is one of the most common uses for Visual Basic code. Setting properties in code allows you to change properties while a program runs.
    • A command button with an ampersand (&) in front of a letter in the Text property causes that letter to become an access key.
  • Summary (cont.)
    • The command button named in the form’s AcceptButton property will be activated when the user presses the Enter key. The command button named in the form’s CancelButton property will be activated when the user presses the Esc key.