Upcoming SlideShare
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Standard text messaging rates apply

# Ppt lesson 06

285
views

Published on

Published in: Technology, News & Politics

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total Views
285
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
4
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Transcript

• 1. Microsoft Visual Basic 2005 BASICS Lesson 6 Exponentiation, Order of Operations, and Error Handling
• 2. Objectives
• Use the exponentiation operator to raise numbers to a power.
• Describe the order of operations.
• Use the Visible property to enhance output.
• Describe the purpose of comments in programs.
• 3. Objectives (cont.)
• Handle run-time errors using the Try/Catch structure.
• Display messages using the MsgBox function.
• Control program flow using the Exit Sub statement.
• 4. Exponentiation
• Exponentiation
• Process of raising a number to a power
• Represented by the caret (^)
• Operator raises the number to the left of the operator t o the power that appears on the right of the operator
• 5. Order of Operations
• Recall the rules called the order of operations
• Visual Basic
• Uses the same set of rules for its calculations
• Parentheses
• Override the order of operations
• 6. Order of Operations (cont.)
• 7. Order of Operations (cont.)
• Basic order of operations
• Exponentiation
• Unary plus and minus
• Multiplication, division, integer division, modulus
• 8. Order of Operations (cont.)
• 9. Order of Operations (cont.)
• 10. Order of Operations (cont.)
• 11. Using the Visible Property to Enhance Output
• Visible property
• Prevents labels from appearing until you are ready for the user to see the label
• By initially setting the Visible property to False
• Output will remain invisible until you make the labels visible in the code
• 12. Using the Visible Property to Enhance Output (cont.)
• Use an apostrophe to create comments.
• Comments can appear on their own lines.
• Explain the purpose of a program
• Keep notes regarding changes to the source code
• Store the names of programmers for future reference
• Explain the parts of your program
• Temporarily remove lines from the program during testing
• 15. Handling Run-Time Errors
• Exceptions or run-time errors
• Errors that occur when the program is running
• Run-time errors are not detected at the time the program is compiled.
• 16. Handling Run-Time Errors (cont.)
• When a run-time error occurs
• The system throws an exception.
• A signal is sent to the program that needs to be handled or caught.
• 17. Handling Run-Time Errors (cont.)
• 18. Trapping Run-Time Errors with the Try/Catch Structure
• Write code that will execute when a run-time error occurs.
• You must turn on error trapping.
• Place a Try statement above the code that may generate a run-time error.
• Code is often called an error handler.
• 19. Trapping Run-Time Errors with the Try/Catch Structure (cont.)
• Error trapping
• Process of interrupting the normal chain of events and replacing that chain with your own code
• 20. Trapping Run-Time Errors with the Try/Catch Structure (cont.)
• 21. Using MsgBox
• MsgBox function
• One of the easiest ways to display a message of your own
• Such as an error message
• Causes a dialog box to pop up
• Displays a message that you specify
• 22. Using MsgBox (cont.)
• 23. Using Exit Sub to Exit a Subroutine
• The Exit Sub statement
• Forces the event procedure to end
• Regardless of whether there is more code in the procedure
• Can be placed anywhere in the subroutine
• Allows the programmer to exit the subroutine for different reasons
• 24. Using Exit Sub to Exit a Subroutine (cont.)
• 25. Summary
• The exponential operator (^) raises a number to a power.
• The rules that dictate the order in which math operators are applied in a formula are called the order of operations.
• Parentheses can be used to override the order of operations.
• 26. Summary (cont.)
• The Visible property can be used to hide a label until you are ready for the user to see it.