Distance Learning Center - PowerPoint PPT Presentation

1 / 36
About This Presentation
Title:

Distance Learning Center

Description:

Display the Hello World message in Spanish. messageLabel.Text = 'Hola Mundo' End Sub ... Common7 - Graphics - Icons - Flags. May 23, 2005. Lecture 3 - by M. Lin. 27 ... – PowerPoint PPT presentation

Number of Views:27
Avg rating:3.0/5.0
Slides: 37
Provided by: melis76
Category:

less

Transcript and Presenter's Notes

Title: Distance Learning Center


1
Distance Learning Center
  • Lecture 3
  • Introduction to Visual Basic
  • Programming
  • Melissa Lin, IT Consultant
  • HenEm, Inc. Parkville, Missouri
  • linm_at_ipfw.edu
  • http//www.etcs.ipfw.edu/linm

2
Lecture 3
  • Modifying the example 1 from last class
  • Finding and Fixing Errors Debugging
  • Chapter 2 User Interface Design
  • Using controls
  • Setting Properties
  • Objects
  • Coding for the controls
  • Summary

3
Review Chapter 1
Help
Solution Explorer
Toolbox
frmHello Design
Properties
Click on Project1
On the Start page, click on the project1 from the
open an existing project, or Open it from the VB
File menu and choose Open
4
Chapter 1 (continued)Solution Explorer
Properties Windows
code
Form
Scroll
5
Modify Projects Add new controls
Label
Font
6
Modify Projects Change Font
Size
Font Style
7
Modify Projects (continue) Change Text Alignment
and Text
8
Modify Projects (continue) Add a Spanish Button
9
Modify Code - Spanish Button
Name Property spanishButton
Object Button
Text PropertySpanish
Hola Mundo is assigned to messageLabel.Text at
the current instance of a class.
Spanish
Private Sub spanishButton_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles spanishButton.Click ' Display the
Hello World message in Spanish.
messageLabel.Text "Hola Mundo" End Sub
10
Modify Projects
11
Explore the Editor Window
Class
Method
Class
12
Modify the Project
  • Understand the Program
  • Plan and Design the GUI of Visual programming
  • Named controls
  • Define properties for each object
  • Code procedures
  • Write Remarks
  • Option Strict On
  • Save and compile
  • Finding and Fixing Errors Debugging
  • Implementation

The Form and all of the Controls on the form
are Objects.
Type this at the top of each code module.
13
Modify Projects
14
Save, Run, Close, Correct
  • SAVE - Open the VB File menu and choose Save or
    Save As to save the project
  • Run Build the project
  • Debug Menu, Start
  • Start (F5)
  • Start Without Debugging (CTRL F5)
  • Close - Open the VB File menu and choose Close or
    Close it from the browser
  • Correct any Errors and Rerun
  • Syntax errors (Compile errors)
  • Run-Time Errors
  • Logic errors

"Help is always available from the Help Menu or
by pressing F1."
15
Finding and Fixing Errors
  • Programming errors come in three varieties
    Syntax Errors, Run-Time Errors, Logic Errors
  • Syntax Errors (Compile Errors)
  • Statements that break VBs rules for punctuation,
    format or spelling
  • Smart editor finds most syntax errors, compiler
    finds the rest
  • Common sources of syntax errors are misspelling
    an object name, property or method, keywords, or
    using wrong punctuations

16
Finding and Fixing Errors (continued)
  • Syntax
  • Error
  • Error
  • Message

17
Finding and Fixing Errors (continued)
  • Run-time Errors
  • Statements or functions that fail to execute such
    as impossible arithmetic operations, or
    unexpected termination
  • Common source of these errors include division by
    zero, attempting arithmetic operations on
    non-numeric data, and taking the square root of a
    negative number
  • Example Dim x As Double
  • x Math.Sqr(-5)

18
Finding and Fixing Errors (continued)
  • Logic Errors
  • Logic errors occur when the project runs but
    produces incorrect results
  • Common sources of these errors include incorrect
    calculations, display of the wrong information,
    or incorrect formatting of output
  • These are generally the hardest errors to fix!
  • They are errors made by the programmer or
    designer
  • Well commented programs enable another programmer
    to read the code and correct logic errors
  • Example area 2 pi r

19
Finding and Fixing Errors (continued)
  • VB Modes
  • Design Time
  • Run Time
  • Break Time
  • Option Explicit (in General code of each module)
  • Comments
  • Naming conventions (helloForm, messageLabel,
    exitButton)

Debug Menu while running
Debug Menu before Starting
Stop Button
Break Button
Start Button
20
Chapter 2More Controls - Toolbox
  • More Controls
  • types
  • Text box
  • Check box
  • Radio button
  • Group box
  • Picture box

21
Text Boxes
  • TextBoxes
  • Allows for user input
  • Text Property
  • What is displayed in text box
  • What user entered in text box
  • TextAlign Property
  • Controls alignment of text in the text box

Select Alphabetical
22
Group Boxes
  • GroupBox
  • Used as containers for other controls such as
    radio buttons and check boxes
  • Improves readability of form
  • Text Property
  • What is displayed on the top edge of the group box

23
Check Box
  • CheckBox (can select more than one at a time)
  • Allows the user to select or deselect one or more
    items in any group
  • Checked Property
  • Checked True
  • Unchecked False
  • CheckedChanged Event
  • Text Property
  • What is displayed next to the check box

24
Radio Buttons
  • RadioButtons (only one selection at a time)
  • User may select only one in any group
  • First create a group box and then create each
    radio button inside the group box
  • Checked Property
  • Checked True
  • Unchecked False
  • CheckedChanged Event
  • Text Property
  • What is displayed next to the radio button

25
Picture Boxes
  • Picture Box control
  • Displays/contains an image
  • Image Property
  • Complete path and filename of graphic
  • .bmp, .gif, .jpg, .jpeg, .png, .ico, .emf, .wmf
  • SizeMode Property
  • StretchImage causes picture to be resized to
    match the size of the control
  • Visible Property

Image Properties button
26
Picture Boxes (continue)
Properties button
Program Files -gt Microsoft Visual Studio .NET2003
-gt Common7 -gt Graphics -gt Icons -gt Flags
27
Picture Boxes (continue)
  • Images can be placed in a PictureBox

To place a size in the PictureBoxObject choose
from SizeMode Property
C\Program Files\Microsoft Visual Studio
.NET\Common7\Graphics\icons\Flags
28
Borders and Styles
  • BorderStyle Property
  • None
  • FixedSingle
  • Fixed3D

29
Drawing Lines
  • Create a Label Object on a Form
  • Clear the Text property
  • Change the Backcolor to the desired color of the
    line
  • Set the BorderStyle property to None

4 Lines
30
Multiple Controls
  • Select Multiple Controls
  • Shift-Click or Ctrl-Click to select/deselect
    multiple controls
  • Move, Align, Set common properties
  • Select
  • Hold left mouse button down to drag a selection
    box around multiple controls OR hold control key
    down while selecting OR hold shift key-down while
    selecting
  • To move as a group just click on any one and drag
    all
  • Common properties are shown in Properties window
  • Format/Align/Size/Spacing allows various group
    changes
  • Deselect
  • Click elsewhere on form

31
Multiple Controls (continue)- Group
  • Point to one corner of a box surrounding the
    controls, press the mouse button and drag to the
    opposite corner
  • When lease the mouse button, each control has
    selection handled
  • You can move, resize, and align them as a group

32
Multiple Controls (continue)- Multiple Group
33
Multiple Controls (continued)- Formatting
Multiple Controls
34
What Can be Done with Multiple Selected Controls?
  • Move them as a group
  • Set their common properties
  • Use Format Menu or Layout Toolbar to
  • Align them to each other
  • Make same size
  • Modify the spacing between them

35
Summary
  • Modify the example from last class
  • Finding and Fixing Errors
  • Syntax Error, Run-time Errors, Logic Errors
  • Chapter 2 User Interface Design
  • Use more controls
  • Set Properties
  • Next
  • Design for User Convenience

36
Question?
  • Answers
  • linm_at_ipfw.edu
  • lin_at_ipfw.edu
  • BnBartholme_at_hotmail.com
Write a Comment
User Comments (0)
About PowerShow.com