1 / 8

Visual Basic: Week 5

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. Review. Visual Basic development includes Placing controls on the form Textbox, label, command button, list box, image control

margo
Download Presentation

Visual Basic: Week 5

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. 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.

  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

  3. Code • Assignment statements target = expression • If/Then/Else • Select Case • For/Next

  4. Built-in functions • Int • Randomize, Rnd • Str • Val • Format

  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.

  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.

  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.

  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.

More Related