Presentation is loading. Please wait.

Presentation is loading. Please wait.

Visual Basic: Week 5 Review User defined functions

Similar presentations


Presentation on theme: "Visual Basic: Week 5 Review User defined functions"— Presentation transcript:

1 Visual Basic: Week 5 Review User defined functions
Busy wait versus Timers Homework: read chapter 4. Acquire images for ‘cards’. Will work on Memory in class. Two more projects before Spring vacation. Will post practice quiz.

2 Review Visual Basic development includes Placing controls on the form
Textbox, label, command button, list box, image control Control arrays of any type control Writing code for event procedures Form_Load, command button Click, list box Click Any others?

3 Code Assignment statements If/Then/Else Select Case For/Next
target = expression If/Then/Else Select Case For/Next Anything else?

4 Built-in functions Int Randomize, Rnd Str Val Format Any others?

5 Event procedures Also known as event handlers
Visual Basic defines them. Defines the header. Visual Basic invokes them when an event happens. You write the code to do something—what you want to happen when a specific event occurs. You write the code in the code window, which you get to by double clicking on the specific control. Code in the wrong event procedure won’t do what you want.

6 Controls Each control type has its own set of properties
All control types have (name) Many have position properties: Left, Top Form, command button and Label have Caption Textbox has Text (can be changed by player) Command button (also Timer) has Enabled. Many have Visible. Image has Picture. Properties can be changed at Design time and by code during Run time. Design time: The (name) is at the top of the Properties window. The properties window is for the selected control on the form. Properties can be changed implicitly by moving a control or changing its size or creating new elements of a control array or by directly changing the properties.

7 Control array event procedure
Suppose lblCards is an array of label controls The event procedure for clicking on any of the elements of the control array is Sub lblCards_Click(Index as Integer) Where Index will hold the index for the specific element clicked. You use Index in your code. For example, you will use this in Memory. This will be used in many projects.

8 Creating a User-Defined Procedure
A user defined procedure is one in which you define (author) the header as well as write the code. User defined procedures can be functions or subroutines, meaning they can return values or not. Call setupcards If hittarget(x,y) then You write the user defined procedure in the code window. Don’t write it inside another procedure.


Download ppt "Visual Basic: Week 5 Review User defined functions"

Similar presentations


Ads by Google