Some Useful Properties: - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

Some Useful Properties:

Description:

The steps for creating a VB program: Create the Interface. Set Properties for the objects. ... Create the interface. Set Properties. Double click on the object ... – PowerPoint PPT presentation

Number of Views:12
Avg rating:3.0/5.0
Slides: 24
Provided by: CET
Category:

less

Transcript and Presenter's Notes

Title: Some Useful Properties:


1
(No Transcript)
2
Some Useful Properties
  • Name
  • Caption
  • Border style
  • Visible
  • Back Color
  • Alignment
  • Font

3
Naming Objects
  • Use the Property window to change the Name
    property of an object
  • Good Programming habit is that each name begins
    with three letter prefix that identifies the type
    of control.

4
Naming Objects
5
Visual Basic Events
  • Code is a set of statements that will be executed
    when you run a program.
  • Write Code for each Event.
  • Most Events are associated with Objects.
  • The code for each event is called an Event
    Procedure.

6
The steps for creating a VB program
  • Create the Interface.
  • Set Properties for the objects.
  • Write the code that executes when event occur.

7
An Event Procedure Walkthrough
  • Create the interface.
  • Set Properties.
  • Double click on the object to open the Code
    window.
  • Click on the Procedure box to find the event
  • Write the code for that event.

8
Example
  • Private Sub cmdButton_Click( )
  • txtBox.ForeColor vbRed
  • txtBox.Font.Size 24
  • txtBox.Text Hello
  • End Sub

9
Components of Visual BASIC Statements
  • Variables
  • Keywords (reserved words)
  • Constants

10
Variables
  • A storage location in main memory whose value can
    change during program execution.
  • These storage locations can be referred to by
    their names.
  • Every variable has three properties a Name, a
    Value, and a Data Type.
  • Types of variables Numeric and String

11
Numeric Variables
  • Used to store Numbers .
  • The value is assigned either by the programmer or
    by calculation.

12
Constant
  • Similar to a variable, but can NOT change during
    the execution of a program.
  • Types of Constants
  • numeric constants
  • string constants

13
Valid Numeric Constants
  • Integer Real number
  • -2987 -1900.05
  • 16 0.0185
  • 5 10.56

14
Numeric Constants in a Statement
  • tax 0.02 (income - 500 dependence)
  • sum 2 x 4.6 y

15
String Constants
  • A group of alphanumeric data consisting of any
    type of symbols.

16
Arithmetic Operations Hierarchy of Operations
  • Operator operation Basic expression
  • Exponentiation A
    B
  • Multiplication A
    B
  • / Division
    A / B
  • Addition
    A B
  • - Subtraction
    A - B

17
Examples
  • Evaluate the following expressions
  • x 3 6 - 12 / 3
  • x 4 (8 / 4)
  • y 12 6 / (3 (10 - 9))
  • z 5 4 2
  • m 6 / 3 3

18
Keywords
  • Words that have predefined meaning to Visual
    Basic .
  • Can Not be used as variable names.
  • Example Print
  • Cls
  • If
  • While

19
Visual Basic Print Statement
  • Print Is a method used to display data on the
    screen or printer.
  • Can be used to print value of variables.
  • Can be used to print value of arithmetic
    expressions .

20
Example of Print Statements
  • Private Sub cmdCompute_Click()
  • picResults.Print 3 - 2
  • picResults.Print 3 2
  • picResults.Print 3 / 2
  • picResults.Print 3 2
  • picResults.Print 2 (3 4)
  • End Sub

21
Example of Print Statement
  • picOutput.Print speed
  • picOutput.Print taxRate
  • picOutput.Print Class average is total / 3

22
Example
  • x 15
  • y 5
  • picOutput.Print (x y) / 2, x / y

23
Output
  • 10 3
Write a Comment
User Comments (0)
About PowerShow.com