1 / 10

13 – Control Arrays & Container Controls

13 – Control Arrays & Container Controls. Assignment. Object naming conventions: txt – text box btn – command button pic – picture box Appropriate use of: indentation remarks constants (no magic numbers) variables (module level, and local) procedures/functions arrays structures

ida
Download Presentation

13 – Control Arrays & Container Controls

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 13 – Control Arrays & Container Controls

  2. Assignment • Object naming conventions: txt – text box btn – command button pic – picture box • Appropriate use of: • indentation • remarks • constants (no magic numbers) • variables (module level, and local) • procedures/functions • arrays • structures • enumerate data types

  3. Project Files • Ensure that you submit: • project file (*.vbp) • all form files (*.frm, and *.frx) • all module files (*.bas)

  4. Session Aims & Objectives • Aims • To introduce the idea of control arrays • To introduce the idea of container controls • Objectives,by end of this week’s sessions, you should be able to: • Create and use a control array • Create and use a container control

  5. Control Arrays • Several controls have same name • Distinguished by unique index • Very similar to a variable array • Makes it easier to do same thing to all controls – using for loop

  6. Example: Ships - UI • Four controls share same name (picMain): picMain(1) picMain(0) picMain(2) picMain(3) lblMooringID

  7. Example: Ships - Code Option Explicit Sub Draw() Dim i As Long For i = 0 To 3 picMain(i).DrawWidth = 3 picMain(i).Line (1000, 1000)-(2000, 1000) picMain(i).Line -Step(-200, 200) picMain(i).Line -Step(-600, 0) picMain(i).Line -Step(-200, -200) Next End Sub Private Sub picMain_Click(Index As Integer) lblMooringID.Caption = Index Draw End Sub

  8. Control Arrays - How • To create a control array, either: • Create a control with the same name as an existing control (VB will ask you if you want to create a control array) Or: • Create a control and type a value into its index property (e.g. 0)

  9. Container Controls • Some controls can contain other controls: • Picture boxes • Frames • The container (parent) control clips the contained (child) controls • The child controls will not be displayed outside the boundary of their parent

  10. Example – Pic Container • The inner picture box is clipped: picOuter picInner

More Related