1 Microsoft® Visual Basic®.NET Language # 2. 2 Flow-Control Statements If … End If Select Case … End Select For… Next Do … Loop Exit.

Slides:



Advertisements
Similar presentations
CSI 1306 PROGRAMMING IN VISUAL BASIC PART 2. Part 2  1. Strings  2. Translating Conditional Branch Instructions  3. Translation Set 2  4. Debugging.
Advertisements

Quiz 2. Quiz 2 What is output (5 Marks) [8 min] X = 987 Y = X Z = 0 Do Do While (Y > 0) Z = Z + Y Mod 10 Y = Y \ 10 Loop Y = Z Z = 0 Loop Until (Y < 10)
1.
IS437: Fall 2004 Instructor: Dr. Boris Jukic Program Flow Control: Decisions and Conditions (Branching) Controlled Repetition (Looping)
Compunet Corporation1 Programming with Visual Basic.NET Selection Structure If-Else Week 4 Tariq Ibn Aziz.
Slide 1 VB Program Flow Control. Slide 2 Making Decisions v Decision Statement: control the execution of parts of the program based on conditions. v The.
.NET Framework.NET Framework class libraries: A large set of classes that forms the basis for objects that can be used programmatically. –Programming in.
CIS 375—Web App Dev II VBScript. 2 Introduction to VBScript VBScript is a light version of MS’s ____________. Example: document.write("Hello from VBScript!")
פתרון תרגילים #9. דוגמה פשוטה #1 Module Module1 Sub Main() Dim x As String x = Console.ReadLine For i = 1 To x.Length() - 1 Step 2 Console.WriteLine(x(i))
VBA & Excel Barry L. Nelson IEMS 465 Fall Quarter 2003.
Repetition Statements Repeating an Action A specified number of times While a Condition is True Until a Condition is True.
1 Visual Basic for Applications (VBA) for Excel Prof. Yitzchak Rosenthal.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Microsoft Access Using Visual Basic Routines. Visual Basic Datatypes Boolean Byte Currency Date Double Integer Long Object Single String Variant Hyperlink.
Language Elements 1. Data Types 2 Floating Point (real) Single Precision Double Precision Decimal Fixed Point (integer) Byte Short Integer Long Numerical.
情報基礎 B Lecture 8 Takeshi Tokuyama Tohoku University Graduate School of Information Sciences System Information Sciences Design and Analysis of Information.
1 CC111 Lec9 : Visual Basic Visual Basic (3) Lecture 9.
ENGR 112 Decision Structures.
VB Core II Conditional statements Exception handling Loops Arrays Debugging.
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.
1 Flow Control II Code: Select-Case and For-Next Controls: Frames and OptionButtons.
Visual Basic 6.0 – (I) 정보물리. 프로시져, 함수, 메소드 프로시져 : Public Sub Multiply (X As Integer,..) Do something End Sub Return 값 ( 반환값 ) 이 없다.
Statements That Repeat. For...Next Loop Structure For counter = start To end Step increment statements Next counter Where Counter is tested to see if.
Variables,Constants and Data types Variables temporarily stores values during the execution of an application Variables have a name and data type Declare.
Visual Basic Programming Making Decisions: Loops & Decision Structures ©Copyright by Ronald P. Kessler, Ph.D.
Introduction to VB.NET 2005 Dr. McDaniel IDS4704 Spring 2005.
Visual Basic.net Loops. Used to do multiple executions of the same block of code Do while loops Do until loops For next loops.
EIW - ASP Introduction1 Active Server Pages VBScript.
Saeed Ghanbartehrani Summer 2015 Lecture Notes #5: Programming Structures IE 212: Computational Methods for Industrial Engineering.
Lab 4 Range Review, Control Logic and Loops ► Range Review ► Control Logic and Loops ► Exercise.
Repetition Structures
Copyright © 2001 by Wiley. All rights reserved. Chapter 6: Using Arrays Control Arrays List Arrays Finding Items in Arrays Multiple Forms 2-Dimensional.
Introduction to Programming Lecture Note - 2 Visual Basic Programming Fundamentals.
Visual Basic Programming I 56:150 Information System Design.
Macro’s Within excel. Most functionality can be driven from VBA VBA is the programming language that runs inside of excel. It uses visual basic as the.
Looping Structures Do Loops, For Next Do...Loop While structures check the condition after executing the code and repeat a code block until the test.
VBScript Conditional Statements. Conditional Statements Very often when you write code, you want to perform different actions for different decisions.
Created by Alia Al-Abdulkarim 2008 Visual Basic Vs. Java.
Visual Basic CDA College Limassol Campus COM123 Visual Programming 1 Semester B Lecture:Pelekanou Olga Week 5: Useful Functions and Procedures.
Introduction to Programming Lecture 2 Msury Mahunnah, Department of Informatics, Tallinn University of Technology.
For…Next and Do...While Loops! Happy St. Patrick’s Day!
Controlling Program Flow with Looping Structures
Lab 6 (1) Range Review, Control Logic and Loops ► Control Logic and Loops ► Exercise.
Controlling Program Flow with Decision Structures.
Visual Basic Review LBS 126. VB programming Project Form 1Form 2Form 3 Text boxButton Picture box Objects Text box Button Objects.
MIC305 Week 6 Beyond controls Review of properties Differences with VB6: using classes and instances Programming constructs.
Dani Vainstein1 VBScript Session 5. Dani Vainstein2 What we learn last session? Branching Branching using If … Then … Else statement. Branching using.
Lecture 7 Methods (functions and subroutines) Parameter Passing
CE En 270 Brigham Young University Norm Jones
Recursion and Branching By: Engr. Faisal ur Rehman CE-105T Spring 2007 By: Engr. Faisal ur Rehman CE-105T Spring 2007.
Kondisi dan Perulangan
Kondisi dan Perulangan
Introduction to Programming Lecture 2
IE 8580 Module 4: DIY Monte Carlo Simulation
VB Script V B S.
UNIT 5 Lesson 15 Looping.
Visual Basic 6 (VB6) Data Types, And Operators
Problem Solving and Control Statements: Part 2
4. Functions and Control Statements
Final Exam Review Part 4 - VBA
البرمجة بلغة فيجول بيسيك
مراحل كتابة البرنامج بلغة فيجول بيسك ستديو
حلقات التكرار.
1.الدوال Function 2.الاجراءاتSub Procedure 3.وحده نمطيه Add Module
المحاضرة السادسة.
Chapter (3) - Looping Questions.
Visual Basic Programming
ASP control structure BRANCHING STATEMENTS
Sub 範例 Sub F ( X ) MsgBox(X ^ 2 ) End Function
Introduction to Computer Programming IT-104
Presentation transcript:

1 Microsoft® Visual Basic®.NET Language # 2

2 Flow-Control Statements If … End If Select Case … End Select For… Next Do … Loop Exit

3 If … End If If {Condition} Then … End If If {Condition} Then … Else … End If If {Condition1} Then … ElseIf {Condition2} Then … End If Example: If Score>80 Then Result = "A" ElseIf Score>50 Then Result = "B" Else Result = "F" End If

4 Select Case … End Select Select Case {Expression} Case {value1} … Case {value2} …. Case Else … End Select Example : Select Case Score Case 80 To 100 Result = "A" Case 70 To 79 Result = "B" Case 60 To 69 Result = "C" Case Else Result = "F" End Select

5 Example : Select…Case Select Case Score Case 80 To 100 Result = "A" Case 70 To 79 Result = "B" Case 60 To 69 Result = "C" Case Else Result = "F" End Select Example: If…Then…Else, Select…Case Example: If…Then…Case If Score>80 Then Result = "A" ElseIf Score>50 Then Result = "B" Else Result = "F" End If

6 Example 1:

7 For… Next For {Counter} = {Start} To {End} … Next ‘ or For {Counter} As Integer = {Start} To {End} … Next Example1 : Dim Result As Integer = 0 Dim I As Integer For I = 1 To 5 Result += I Next MsgBox (Result & I) Example2 : Dim Result As Integer = 0 For I As Integer = 1 To 5 Result += I Next MsgBox (Result & I)

8 Do … Loop Do {While/Until} {Condition} … Loop Example1 : Dim Result As Integer = 0 Dim I As Integer = 0 Do Until I>2 I += 1 Result += I Loop MsgBox (Result & I) Do … Loop {While/Until} {Condition} Example2 : Dim Result As Integer = 0 Dim I As Integer = 0 Do While I < 2 I += 1 Result += I Loop MsgBox (Result & I)

9 Exit Exit from block of statements in a control structure. Example : Dim I As Integer = 0 Dim Result As Integer = 0 Do Until I>4 I += 1 Result += I If Result>5 Then Exit Do End If Loop MessageBox.Show (Result & I)

10 Sub {Scope} Sub {name}({param1}…) End Sub Public Sub SayHello(ByVal Name As String) MessageBox.Show ("Hello " + Name) End Sub Public Sub SayHello() MessageBox.Show ("Hello World") End Sub Call SayHello("Peter")

11 Function {Scope} Function {name}({param1}…) As {Type} End Sub Public Function Add(ByVal Val1 As Integer, ByVal Val2 As Integer) As Integer Return Val1+Val2 End Sub A = Add( 3, 4 ) Public Function Add() As Integer Return 0 End Sub