0 index
1 Objects
2 An object has:
3 Selected Controls
4 Sample Code:
5 Picture box
6 Sample Code:
7 Label
8 Text box
9 Command Button
10 Sample Code:
11 Scroll bar
12 Sample Code:
13 Option button
14 Check box

outline
created using slideshow.cgi by Andy Harris















CSCI N331 Visual Basic: n331/VB02 Controls
1. Objects
  • Characteristics
       -building blocks of Visual Basic
       - Object types already created - we make new instances
       - Object types ' borrowed' from Windows environment
       - Individual entities that are somewhat self-contained
       - Can interact with other objects
       - Some behavior 'built-in'



































CSCI N331 Visual Basic: n331/VB02 Controls
2. An object has:
  • Properties - individual characteristics of the object
  • Events - stimuli from the user, environment, or other objects that the object can respond to
  • Methods - specialized commands that the object can do - allows you to manipulate



































CSCI N331 Visual Basic: n331/VB02 Controls
3. Selected Controls
  • Form - abbreviation: frm
       - main property: varies
       - main event: load (activated whenever the form shows up on screen)
       - main uses; serves as a container for all other controls
       - background for the program
       - load event used to contain code for early in the program run



































CSCI N331 Visual Basic: n331/VB02 Controls
4. Sample Code:
  • Private Sub Form_Click()
    'when clicked show in the label that this
    'is a form

    lblLabel.Caption = "This is the Form"
    End Sub



































CSCI N331 Visual Basic: n331/VB02 Controls
5. Picture box
  • Main property: Picture
  • Main event: click
  • Abbreviation: pic
  • Main uses: display graphic image on screen



































CSCI N331 Visual Basic: n331/VB02 Controls
6. Sample Code:
  • Private Sub picIUPUI_Click()
    'when clicked show in the label this is a
    'picture box

    lblLabel.Caption = "This is a Picture Box"
    End Sub



































CSCI N331 Visual Basic: n331/VB02 Controls
7. Label
  • Main property: caption
  • Main event: click
  • Abbreviation: lbl
  • Main uses: primary form of text OUTPUT in VB, display text on screen show text that the user cannot directly change, works like print command in other languages



































CSCI N331 Visual Basic: n331/VB02 Controls
8. Text box
  • Main property: text
  • Main event: change
  • Abbreviation: txt
  • Main uses: primary form of text INPUT in VB, displays CHANGEABLE text on screen, often works like INPUT command in other languages



































CSCI N331 Visual Basic: n331/VB02 Controls
9. Command Button
  • Main property: caption
  • Main event: click
  • Abbreviation: cmd
  • Main uses: indicated user's desire to do something, frequently houses significant amount of program code, graphically shows being depressed, easily recognized as something to click



































CSCI N331 Visual Basic: n331/VB02 Controls
10. Sample Code:
  • Private Sub cmdQuit_Click()
    'when the user clicks here end the program
    End
    End Sub



































CSCI N331 Visual Basic: n331/VB02 Controls
11. Scroll bar
  • Main property: value
  • Main event: change
  • Abbreviation: hsc (horizontal), vsc (vertical)
  • Main uses: primary form of INTEGER input in VB, allows user to input numeric value graphically, range can be determined at design time, allows little opportunity for error



































CSCI N331 Visual Basic: n331/VB02 Controls
12. Sample Code:
  • Private Sub hscHorizontal_Change()
    'when the user moves the scrollbar indicate in the
    'label that this is a horizontal scroll bar

    lblLabel.Caption = "This is a horizontal scroll bar " & hscHorizontal.Value
    End Sub



































CSCI N331 Visual Basic: n331/VB02 Controls
13. Option button
  • Main property: value (true or false)
  • Main event: click
  • Abbreviation: opt
  • Main uses: allows user to check ONLY ONE of a series of options, grouped in a form or frame, when one is true all others are false, like a car radio



































CSCI N331 Visual Basic: n331/VB02 Controls
14. Check box
  • Main property: value (checked, unchecked or grayed)
  • Main event: click
  • Abbreviation: chk
  • Main uses: allows user to check one OR MORE of a series of options, can also be grouped, more than one can be checked at a time



































outline

Objects

An object has:

Selected Controls

Sample Code:

Picture box

Sample Code:

Label

Text box

Command Button

Sample Code:

Scroll bar

Sample Code:

Option button

Check box