Presentation is loading. Please wait.

Presentation is loading. Please wait.

Mark Dixon, SoCCE SOFT 131Page 1 13 – Control Arrays & Container Controls.

Similar presentations


Presentation on theme: "Mark Dixon, SoCCE SOFT 131Page 1 13 – Control Arrays & Container Controls."— Presentation transcript:

1 Mark Dixon, SoCCE SOFT 131Page 1 13 – Control Arrays & Container Controls

2 Mark Dixon, SoCCE SOFT 131Page 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 Mark Dixon, SoCCE SOFT 131Page 3 Project Files Ensure that you submit: –project file (*.vbp) –all form files (*.frm, and *.frx) –all module files (*.bas)

4 Mark Dixon, SoCCE SOFT 131Page 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 Mark Dixon, SoCCE SOFT 131Page 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 Mark Dixon, SoCCE SOFT 131Page 6 Example: Ships - UI lblMooringID picMain(3) picMain(1) picMain(2) picMain(0) Four controls share same name (picMain):

7 Mark Dixon, SoCCE SOFT 131Page 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 Mark Dixon, SoCCE SOFT 131Page 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 Mark Dixon, SoCCE SOFT 131Page 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 Mark Dixon, SoCCE SOFT 131Page 10 Example – Pic Container The inner picture box is clipped: picInner picOuter


Download ppt "Mark Dixon, SoCCE SOFT 131Page 1 13 – Control Arrays & Container Controls."

Similar presentations


Ads by Google