Practical Programming COMP153-08S Lecture: Repetition.

Slides:



Advertisements
Similar presentations
Midterm 26 March 2015 (4:30-5:30 pm) – Rm5620 Closed book exam MC Questions only x25 Up to L(7) Methods Scope: video lectures (+Lab), forum discussions,
Advertisements

Practical Programming COMP153-08S Lecture: Repetition Continued.
CS0004: Introduction to Programming Repetition – Do Loops.
Making a cartoon or slideshow. Aside VB comments An apostrophe starts a comment to end of line Some of the following slides have code with comments in.
Compunet Corporation Programming with Visual Studio.NET GUI Week 13 Tariq Aziz and Kevin Jones.
ASP.Net AJAX. AJAX Asynchronous JavaScript and XML: – JavaScript, Document Object Model, Cascade Style Sheet, XML, server-side script such as.Net, etc.
Arrays. Declaring a Array With subscript: –Dim numbers(2) as Integer –Using variable as subscript: Dim arrayIndex as Integer = 10 Dim myArray(arrayIndex)
More on lists, exceptions, loops and validation. You can use the exception to indicate the error that occurred Private Sub btnCheck_Click(ByVal sender.
Visual Basic: An Object Oriented Approach 3 – Making Objects Work.
Chapter 8 Using Repetition with Loops and Lists. Class 8: Loops and Lists Write Do loops to execute statements repeatedly Write For loops to execute statements.
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
MrsBillinghurst. net A2 Computing A2 Computing Projects Game Animation in Pascal.
1 Chapter 9 – Additional Controls and Objects 9.1 List Boxes and Combo Boxes 9.2 Eight Additional Controls and Objects 9.3 Multiple-Form Objects 9.4 Graphics.
COMPUTER PROGRAMMING I Objective 8.03 Apply Animation and Graphic Methods in a Windows Form (4%)
Visual Basic Games: Week 3 Global variables, parameters, Select, KeyDown Enable, Visible, Focus State of Game Read chapter 3.
COM148X1 Interactive Programming Lecture 6. Topics Today Generate Random Numbers Graphics Animation.
Lecture Set 5 Control Structures Part D - Repetition with Loops.
Lecture 8 Visual Basic (2).
1 CC111 Lec9 : Visual Basic Visual Basic (3) Lecture 9.
Chapter 9 - VB.Net by Schneider1 Chapter 9 – Additional Controls and Objects 9.1 List Boxes, Combo Boxes, and the File-Opening Control The List Box Control.
Types and Loops.
VB Games: Preparing for Memory Brainstorm controls & events Parallel structures (again), Visibility, LoadPicture, User-defined procedures, Do While/Loop,busy.
VB.NET Additional Topics
Visual Basic CODE. Basics of Code Declaration Declaration Set aside a named place to put things Set aside a named place to put things Assignment Assignment.
Arrays Code: Arrays Controls: Control Arrays, PictureBox, Timer.
Some graphics. Projects included A slideshow a dark moon moving phases of the moon billiards Your own icons and bitmaps Pie chart.
The PictureBox Control Prefix Prefix – pic Image Property PictureBox Image Property – Changes the image or file that appears inside of the PictureBox SizeMode.
1 Week 6 The Repetition Structure. 2 The Repetition Structure (Looping) Lesson A Objectives After completing this lesson, you will be able to:  Code.
© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 8: Chapter 5: Slide 1 Unit 8 List Boxes and the Do While Looping Structure.
Statements That Repeat. For...Next Loop Structure For counter = start To end Step increment statements Next counter Where Counter is tested to see if.
Tutorial 6 The Repetition Structure
Chapter 4 Looping Statements Adapted From: Starting Out with Visual Basic 2008 (Pearson)
CS0004: Introduction to Programming Project 1 – Lessons Learned.
CONTENTS Processing structures and commands Control structures – Sequence Sequence – Selection Selection – Iteration Iteration Naming conventions – File.
© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 10: Chapter 6: Slide 1 Unit 10 Sub Procedures and Functions Chapter 6 Sub.
6c – Function Procedures Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
Practical Programming COMP153-08S Week 5 Lecture 1: Screen Design Subroutines and Functions.
Practical Programming COMP153-06S Lecture 3: Making Decisions.
1 Advanced Computer Programming Lab Calculator Project.
4-1 Chapter 4 The Selection Process in VB.NET. 4-2 Learning Objectives Understand the importance of the selection process in programming. Describe the.
ITEC 109 Lecture 11 While loops. while loops Review Choices –1 st –2 nd to ?th –Last What happens if you only use ifs? Can you have just an else by itself?
Created by Alia Al-Abdulkarim 2008 Visual Basic Vs. Java.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Graphic Programming Advanced Computer Programming.
Week Procedures And Functions 7 A procedure is a collection of statements that performs a task.
Higher Computing Software Development -So Far- 5/10/10.
Lab 10 Slides.
© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 3: Chapter 3: Slide 1 Unit 3 Formatting Chapter 3 Input, Variables, Constants,
Visual Basic Review LBS 126. VB programming Project Form 1Form 2Form 3 Text boxButton Picture box Objects Text box Button Objects.
Loop and repetition. Today Passing values to and back from Sub procedures Option Buttons Do While Loops For Loops Population Growth.
Fourth Quarter.  Involves loops or cycles ◦ Loops: means that a process may be repeated as long as certain condition remains true or remains false. ◦
Starting Out with Visual Basic.NET 2 nd Edition Chapter 6 Sub Procedures And Functions.
MIC305 Week 6 Beyond controls Review of properties Differences with VB6: using classes and instances Programming constructs.
COM148X1 Interactive Programming Lecture 8. Topics Today Review.
Visual Basic Declaring Variables Dim x as Integer = 0 In the statement above, x is being declared as an Integer (whole number) and is initialised.
Computer Science Up Down Controls, Decisions and Random Numbers.
Sub Procedures And Functions
Visual Basic Fundamental Concepts
UNIT 5 Lesson 15 Looping.
Lesson 16 Sub Procedures Lesson 17 Functions
Data Types, Arithmetic Operations
Lists, Loops, Validation, and More
Chapter 6 – Repetition 6.1 Do Loops 6.2 For...Next Loops
للمزيد زورونا على موقعنا الإلكتروني:
Visual Basic..
Java for Beginners University Greenwich Computing At School DASCO
Boolean Expressions and If statements
Selection Statements.
ICT Programming Lesson 3:
GUI Programming in Visual Studio .NET
Lecture 9: JavaScript Syntax
Presentation transcript:

Practical Programming COMP153-08S Lecture: Repetition

Programming So Far First: Controls, Properties, Events Second: Types and Arithmetic Third: Variables (Global/Local) Fourth: Decisions If and Select This week: Repetition

Repetition Making things happen more than once This is what computers are good at –Doing simple repeated tasks 1.The user can repeat commands 2. The computer can repeat

Computer Repeating Can use Timer controls –Useful when you want things to repeat slowly – eg: graphics, animation Can use looping statements –When you simply want to get a task done as quickly as possible –Easier to program than timers

Timer Control – Digital Clock

Timer dissected Set Timer controls first: Timer1.enabled = True Timer1.Interval = 1000 (1 second) Label1.Text = TimeString( ) (code for timer) –Get current time from system clock as a string. Can change the interval to see the timer control more explicitly

An Aside - Graphics Top left is (0,0) x-axis increases left to right y-axis increases top to bottom (x,y) is a pixel position

Timer Examples Adding to a counter Moving a control

Timer code Import picture set SizeMode PictureBox1.Left = PictureBox1.Left + 2 If PictureBox1.Left > Me.Width - PictureBox1.Width Then PictureBox1.Left = 0 End If

Bouncing lily Dim GoingRight As Boolean Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Enabled = True Timer1.Interval = 1 GoingRight = True End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick If GoingRight Then PictureBox1.Left = PictureBox1.Left + 2 If PictureBox1.Left > ActiveForm.Width - PictureBox1.Width Then GoingRight = False End If Else PictureBox1.Left = PictureBox1.Left - 2 If PictureBox1.Left = 0 Then GoingRight = True End If End Sub

Repetition statements The For / Next statement For x = 1 To 5... Next Note: the variable x must be declared (Dim x as Integer).

Moving Image without timer Dim x As Integer For x = 1 To 5 PictureBox1.Left = PictureBox1.Left + 2 MessageBox.Show(x) Next

Creating new forms dynamically When you want to copy the form you have designed as your program runs –Dim two As Form1 –two = new Form1() and –two.Show()

Example Another example Dim x as Integer Dim f as Form1 For x = 100 To 200 Step 30 f = New Form1() f.Width = x f.Show() Next

THE END of the lecture