meljun cortes visual basic control arrays

Upload: meljun-cortes-mbampa

Post on 04-Jun-2018

226 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 MELJUN CORTES Visual Basic Control Arrays

    1/13

    CONTROL ARRAYS

    MELJUN CORTES

  • 8/13/2019 MELJUN CORTES Visual Basic Control Arrays

    2/13

    Overview

    Definition of Control Arrays

    Characteristics of Control Arrays

    Uses of Control Arrays

    How to create Control Arrays

    Example / Demonstration

  • 8/13/2019 MELJUN CORTES Visual Basic Control Arrays

    3/13

    is a group of controls of the same typethat have thesame nameand share the same set of event procedureor provide similar functionality.

    Definition of Control Arrays

  • 8/13/2019 MELJUN CORTES Visual Basic Control Arrays

    4/13

    Characteristics of Control Arrays

    each control array element maintains its ownproperties

    share its event procedure code with the other controlarray elements

    have minimum lower boundof 0 and a maximum upperbound32767

    control array bounds are not affected by Option Base(unless the programmer specifies otherwise, 0 isalways the lower bound

    each control array element is uniquely identified by itsInteger Index property

  • 8/13/2019 MELJUN CORTES Visual Basic Control Arrays

    5/13

    Uses of Control Arrays

    to group together existing controls

    fewer resources than simply adding multiple controls ofthe same type to a form at design time.

    useful if you want several controls to share code

    Example: if three option buttons are created as a controlarray, the same code is executed regardless of whichbutton was clicked

  • 8/13/2019 MELJUN CORTES Visual Basic Control Arrays

    6/13

    How to create Control Arrays?

    By giving a control the same name as another control

    By copying a forms control and pasting the copy onthe form

    Explicitly setting a controls Indexproperty

  • 8/13/2019 MELJUN CORTES Visual Basic Control Arrays

    7/13

    Control Array Dialog Box

  • 8/13/2019 MELJUN CORTES Visual Basic Control Arrays

    8/13

    Example

    A government lab wants to install a security keypad outside a laboratory

    room. Only authorized personnel may enter the lab, using their securitycodes. The following are valid security codes:

    16451689 = Technician Personnel

    8345 = Custodial Services

    55875 = Special Services

    999898, 10000061000008 = Scientific Personnel

    As an added security measure, the keypad treats any access less than1000 as a panic code by sounding a single beep. Although access is

    denied, security is notified immediately. Once an access code isentered, access is either granted or denied. All access attempts arewritten to a window below the keypad. If access is granted, the date,time, and group (i.e., Technician Personnel, Custodial Services, etc.)are written to the window. If access is denied, the date, time and themessage Access Denied are written to the window.

  • 8/13/2019 MELJUN CORTES Visual Basic Control Arrays

    9/13

    Example: Explained

    True

    True

    True

  • 8/13/2019 MELJUN CORTES Visual Basic Control Arrays

    10/13

    Example: Sample GUI

  • 8/13/2019 MELJUN CORTES Visual Basic Control Arrays

    11/13

    Example: Explained (Case Multiple Selection Structure)

  • 8/13/2019 MELJUN CORTES Visual Basic Control Arrays

    12/13

    Example: Explained (Control Arrays)

  • 8/13/2019 MELJUN CORTES Visual Basic Control Arrays

    13/13

    Review

    Definition of Control Arrays

    Characteristics of Control Arrays

    Uses of Control Arrays

    How to create Control Arrays