Lecture 8 - If statements and Go To

Lecture 8 - If statements and Go To -...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
2/3/2010 1 Today’s Topic Branching and Go To Branching and Go To How this Information will help you You will learn how to enable your VBA programs to “make decisions”. You will learn how to get your programs to repeat actions. Connecting to Your Background Making decisions Gather information Weigh pros and cons If (pros > cons) then Go with this action Else Go with this action End If
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2/3/2010 2 Branching If statements Is x >y? Yes No Do A Do B If (x > y) then Action B Else Action A EndIf If –Else-End If If statements are used to make decisions in your programs If(x>=2.0)then y = 2*x Else y = x/2 End If What will the value of y be when x = 2.0? What will the value of y be when x = 1.5?
Background image of page 2
2/3/2010 3 If –Else If-End If If statements are used to make decisions in your programs
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: If(x>=2.0)then y = 2*x Else If (x<0.5)then y = x/2 End If What will the value of y be when x = 2.0? What will the value of y be when x = 1.5? What will the value of y be when x = .5? What will the value of y be when x =- .5? Go To Go To statement Enables the programmer to send control a specific place in a program If(x > = 2.0)then y = 2*x Else Go To 10 End If If the value of x is 2.0 or greater, y will be 2*x, otherwise (Else) control of the program will be sent to line 10 2/3/2010 4 In Class Assignment Write a VBA program that will find the roots of a quadratic equation 2 1 2 1 , 4 2 2 b x x b ac a a = --2 ax bx c + + = What if 4ac > b 2 ? Sqr(b^2-4*a*c)...
View Full Document

Page1 / 4

Lecture 8 - If statements and Go To -...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online