1 / 75

We’ll start in a moment…

We’ll start in a moment…. Get Ready to Answer These… What is your name? Tell us about your background. Share an interesting story or fact about yourself with the class. What are your hobbies? What do you hope to get from this class? Turn on your computer

desiderio
Télécharger la présentation

We’ll start in a moment…

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. We’ll start in a moment… • Get Ready to Answer These… • What is your name? • Tell us about your background. • Share an interesting story or fact about yourself with the class. • What are your hobbies? • What do you hope to get from this class? • Turn on your computer • Do not enter a login name or password when prompted to do so, simply hit Enter or click the OK button. • Start Internet Explorer • Start Menu • Internet -> Internet Explorer

  2. Visual Basic Programming II Orientation and Lecture 1 MIS 233 Instructor – Larry Langellier

  3. An Important Thing to Know! • The Home Page for the course http://Online.MoraineValley.edu/WebSupported/MIS233-Langellier

  4. The Syllabus • Click the Syllabus link at the top of the Home Page • Details on: • The Instructor • Textbooks • Grading • Prerequisites • Policies and Procedures

  5. Office Location Office Hours Phone Numbers Email Address Prerequisites Textbooks Schedule Policies Withdrawal Refunds Attendance Preparation Cheating/Plagiarism Working Together Cell phones silenced Syllabus Details

  6. Distribution Homework 25% Mini-Projects 25% WebBoard 10% Research Presentation 5% Midterm Project 15% Final Project 20% Late Homework is penalized 20% Homework more than 1 week late will not be accepted Scale A 93 – 100% B 85 – 92% C 76 – 84% D 70 – 75% F Below 70% Syllabus Details - Grading

  7. What will this course be like? • Multiple Learning Styles accommodated Learn by Reading Learn by Listening Learn by Doing Lectures Homework problems Learn by Mistakes “Just Do It!” Exercises Fail early, Fail often Learn by Questioning Learn by Example Ask questions on the WebBoard HW and “JDI” solutions Learn by TeachingExamples in the textbook Answer questions on the WebBoard Learn by Group Interaction Group “Do It Together” Exercises

  8. How to Use the WebBoard • 10% of your grade will be based on participating on the class WebBoard • You must… • Post at least three relevant questions, comments, observations, summaries, pseudocode samples, discussions or answers to the current questions of others • Only serious contributions count! • Light-hearted submissions are welcome • All postings are subject to standards of appropriate conduct • Logon • http://Online.MoraineValley.edu/WebSupported/MIS233-Langellier • Click on WebBoard • Click the New User button • Fill out the User Profile – use your real name and email address!

  9. How to Use the WebBoard • How to Post • For new discussions • Select a Conference • Select Post (at the top) • Enter a topic • Enter your message • Click the Post button • How to Reply • To answer some else’s post that you are reading • Select the “reply” option above the message you are reading • Type in your follow-up message • Click the Post button • Chat

  10. WebBoard Usage • Do • Ask Questions • Post Pseudocode (you’ll learn what that is) • Answer Questions • Discuss class topics • Share design ideas (even on homework assignments) • Clarify poorly worded homework questions (it happens…) • Discuss solutions to past homework exercises • Don’t • Post the code for your homework solutions before the due date • Don’t share your code with anyone, in any way, prior to the due date • Act like a poor citizen in any way • The rules of the college still apply on the Web

  11. Get To Know Your Instructor… • Let’s practice using the WebBoard • Everyone must ask me one question. • Go to the “Your First Post” conference • Post your Question to the WebBoard • The topic should contain a summary of your question • The body of the message could contain a more detailed version of your question • You’ll be able to read my replies tomorrow • Logoff when you’re done

  12. The Course Schedule • Select Master Schedule on the Home Page menu • A summary of each week • Reading Assignments • Topics covered • Homework Deadlines • A good place to see what’s going on at a glance

  13. Topics Covered In This Course • Loops and Decisions • Event-Driven Programming • Debugging • Lists and Arrays • Numeric and String Functions • File Processing • Error Trapping • Classes and Objects • Modular Design • Three-Tier Architecture • Database Access

  14. Topics Not Covered In This Course • Internet Programming • VB.NET (well, there will be some…) • COM Components • Help Systems • n-Tier Architecture • Creating Installations • Advanced Object Modeling and Design • Database Design

  15. Homework • Click the Homework menu item on the Home Page • All assignments and due dates for the semester are listed

  16. Homework • Via Email • Attach .vbp, .vbw, .bas, .cls, .frm, and .frx solution files (only) for the homework assignments • If the assignment includes written exercises, type the written solutions in Microsoft Word or Notepad and submit the .doc or .txt file • The Subject Line of your email message must reflect what class (MIS233), which homework, and your name. e.g. MIS233 HW1 – Joe Blow • Attach all solutions for one week to a single e-mail • No More • No Less • If you are going to be late, wait to submit until you’re done • Microsoft Word will be used to grade homework • http://download.microsoft.com/download/word2000/viewer/1/win98/EN-US/Wd97vw32.exe

  17. Homework • Dues Dates • By the beginning of class on the deadline date listed for the assignment • Late Penalty • 20% for anything one second late to one week late • 100% for everything more than one week late • Only one submission is accepted • You will have to decide whether to turn in partial solutions or take the penalty and turn in late solutions – I won’t accept two submissions • Solutions • Will be returned with your graded homework

  18. Projects and Presentations • Mini-Projects • The Mini-Projects will require you to apply and combine numerous programming concepts you’ve learned to that point to a larger problem that I provide specifications for. • Research Presentation • The field of computer programming changes rapidly. To keep from falling behind you need to stay current with technology changes. This project will require you select an emerging technology related to Visual Basic, research it, and present an oral summary of your findings to the class. I will provide a list of possible topics, but if you’ll also have the opportunity to select your own topic with my permission. • Final Project • The Final Project will be the culmination of all the hard work you do this semester. You will select your own project, design a solution, implement and test the software, create a user guide, and demonstrate your project to the class during the last class period.

  19. Time to answer my questions… • Post a Reply to the WebBoard • Select the “Tell Us About Yourself” Conference • Read the “About the Instructor” posting I made, telling you about myself • Reply (don’tPost like we did before) • Answer some simple questions about yourself • What is your name? • Tell us about your background. • Share an interesting story or fact about yourself with the class. • What are your hobbies? • What do you hope to get from this class? • Feel free to tell us more

  20. Contacting the Instructor • WebBoard • Post questions regarding course content, policies, etc. • Office Hours (listed in the syllabus) • Drop by if you’d like to discuss things in person • By Appointment • If my office hours are impossible for you to attend, feel free to email or phone to see if we can arrange a time • Telephone • (708) 974-5339 • I’m not in the office very often - leave a message if I don’t answer • If one of my office mates answers, ask them to transfer you to voice mail • E-mail • Reserved for items of a personal nature that can’t be posted to the WebBoard (i.e. illnesses, etc.)

  21. Other Materials • Instructor’s Website • http://Online.MoraineValley.edu/Websupported/Langellier/ • Weekly Lecture Notes • PowerPoint summary of the presented materials • “Just Do It!” Hands-on exercises with solutions • Homework Solutions • Returned with your graded homework • Resources • Index

  22. Good Luck!!!

  23. Review • Selection Structures • If…Then…Else • Select Case • Relational Operators • =, >, <, <>, >=, <= • Logical Operators • And, Or, Xor, Not • Input Box and Message Box • The Format() Function • Formatting Numbers, Dates and Time • Random Number Generation

  24. More MIS130 Review • Scope – Variables and Procedures • Procedure-level • Module-level • Global-level • Static • Working with Multiple Forms in an Application • User-Defined Data Types • Loops • For • Do Until • Do While • While • Control Arrays • Timer Control

  25. Control Structures • Computing problems can be solved by executing a series of actions in a specific order - this is called an algorithm • Control structures determine the order statements are executed. All algorithms can be written using three basic control structures: • Sequential • Selection • Repetition • Pseudocode is useful for developing algorithms without writing code. A programmer can “think out” their solution in English prior to writing Visual Basic.

  26. If…Then…Else • Selection structures enable solutions that will (or will not) execute a statement (or sequence of statements) based on the value of a condition • In Pseudocode: If the child is taller than 2’ 6” Display “You may ride the carnival rides” Notice the indentation for the conditionalized action • Visual Basic provides the If…Then and If…Then…Else statements to allow you to “select” whether to execute an action or sequence of actions

  27. If…Then…Else Syntax • Form 1 (on one line) Iftest-conditionThenstatement [Elsestatement] • Form 2 - Example 8.1 Iftest-conditionThen statement block [Else statement block2] End If • Form 3 - Example 8.2 Iftest-conditionThen statement block [ElseIf test-condition2 statement block2] [Else statement block-n] End If

  28. If…Then…Else Example If grade >= 93 Then lblStudentGrade.Caption = "A" Else If grade >= 85 Then lblStudentGrade.Caption = "B" Else If grade >= 76 Then lblStudentGrade.Caption = "C" Else If grade >= 70 Then lblStudentGrade.Caption = "D" Else lblStudentGrade.Caption = "F" End If End If End If End If

  29. If…Then…ElseIf Example If grade >= 93 Then lblStudentGrade.Caption = "A" ElseIf grade >= 85 Then lblStudentGrade.Caption = "B" ElseIf grade >= 76 Then lblStudentGrade.Caption = "C" ElseIf grade >= 70 Then lblStudentGrade.Caption = "D" Else lblStudentGrade.Caption = "F" End If

  30. Test Conditions and Relational Operators • A Test Condition is basically a question you ask that has a True or False (or yes/no) answer Is it raining? Is myName = “Larry”? • The answer may vary depending on • when you ask • what the variable values are when you ask • Relational Operators allow you to compare two values. Visual Basic includes: = Equality <> Inequality > Greater Than >= Greater Than or Equal To < Less Than <= Less Than or Equal To

  31. Logical Operators • Relational Test Conditions can be built into larger test expressions using Logical Operators • For Example: If it is raining and you have your umbrella • Visual Basic provides 3 primary Logical Operators: And True only if both operands are true Or True if one or both operands are true Not True only if the single operand is false

  32. Operator Precedence • Arithmetic, Relational and Logical operators are performed in a specific order within a single expression. This order is determined by precedence rules ^ Exponentiation HIGHEST - Negation (unary operation) *, / Multiplication and Division \ Integer Division Mod Modulo Arithmetic +, - Addition and Subtraction & String Concatenation =, <>, >, >=, <, <= Logical Operators Not Logical Negation (unary operation) And Conjunctive Or Inclusive Or LOWEST

  33. Using If…Then Logic to Manipulate Objects • Examples • A button that constantly shifts between two messages • Example 8.3 • An enhancement to the prior example that displays a message box every sixth time the button is clicked • Example 8.5 • Display different messages depending on where the slider is in a scroll bar • Example 8.6

  34. Sample Problem Provide two text boxes for the user to enter numbers and a “Test Them” button. After the user enters numbers a clicks the button, display a message declaring which number was the largest. If the numbers are both equal, display a message to that effect instead.

  35. Interface Prototype

  36. Sample Pseudocode If the first number is larger Display a message showing the value of the 1st Else if both numbers are equal Display a message saying both are equal Else Display a message showing the value of the 2nd

  37. Sample Solution Private Sub cmdTest_Click() If CInt(txtNum1.Text) > CInt(txtNum2.Text) Then lblMessage.Caption = txtNum1.Text & " is the largest." ElseIf CInt(txtNum1.Text) = CInt(txtNum2.Text) Then lblMessage.Caption = "Both numbers are equal." Else lblMessage.Caption = txtNum2.Text & " is the largest." End If End Sub

  38. Select Case • The If…Then…ElseIf selection statement allows choosing between several alternative courses of action • Visual Basic also provides another statement for choosing among alternatives - the Select Case • Syntax Select Casetestvariable [Caseexpressionlist1 actionlist1] [Caseexpressionlist2 actionlist2] Case Else actionlist-n End Select

  39. Select Case (cont.) • Comma Delimited Multiple expressionlist Case 0, 5, 8, 11, 13 • Range Delimited Expression Case 21 To 27 Case Is >= 20 • Examples • Redo the scroll bar ElseIf example • Example 8.7 • Respond to a job applicant’s salary request • Example 8.8 • Identifying World Capitals • Example 8.9

  40. The Input Box • The InputBox() function displays a dialog box that waits for the user to input a piece of information. • Syntax InputBox(prompt[, title][, default][, xpos][, ypos]) where: prompt is a message displayed in the dialog box; title is displayed in the input box title bar; default is the response if no other input is provided; xpos is the horizontal distance from the left of the screen; and ypos is the vertical distance from the top of the screen InputBox returns a string containing the answer the user input • Example - Using the Input Box for Data Entry (9.1)

  41. The Message Box • The MessageBox() function is used to display information to the user • Syntax MsgBox(prompt[, buttons][, title]) where: prompt is a message displayed in the dialog box; buttons specify the number and type of buttons to display; and title is displayed in the input box title bar • Return Values • vbOK, vbCancel, vbAbort, vbRetry, vbIgnore, vbYes, vbNo • Example - Exploring different MsgBox types (9.2)

  42. Do It Together! Write a program to determine a person’s grade on an exam. Use an InputBox to get their exam score and a MsgBox to display their grade based on that score. The exam grade should be calculated using a Select Case statement where the grade scale is as follows: 93-100 A 85-92 B 77-84 C 70-76 D Below 70 F

  43. Interface Prototypes

  44. Sample Solution Private Sub cmdGrade_Click() Dim nGrade As Integer Dim sMessage As String nGrade = InputBox("Enter your exam score:", "Exam Grader", 0) Select Case nGrade Case Is >= 93 sMessage = "You received an A on the Exam." Case Is >= 85 sMessage = "You received a B on the Exam." Case Is >= 77 sMessage = "You received a C on the Exam." Case Is >= 70 sMessage = "You received a D on the Exam." Case Else sMessage = "You received an F on the Exam." End Select MsgBox sMessage, vbExclamation, "Exam Grade" End Sub

  45. The Format() Function • The Format() function allows you to display values in traditional ways users have come to expect to see them: • Various Date and Time formats • Currency • Percentages • Comma separated thousands • Syntax Format(expression[, format]) where: expression is an valid expression to be formatted; and format is a valid named or user-defined format expression • Example - Entering and Displaying Numeric Data (9.4)

  46. Random Number Generation • Randomize • Should be called once in your program • Establishes a different starting point for the random sequence • Rnd() • Generates a decimal random number between 0 and 1

  47. Random Numbers (cont.) • Scaling • Obviously, you will frequently want random numbers outside this range • To scale to the range of values you want, do the following: • Multiply the random number by how many values are in the range you desire (I.e. There are 101 values if you want the range 0 - 100) • Extract the integer portion of this calculation using the Int function • Add the value of the starting position • Example - The Range 10 To 90 10 + Int(81 * Rnd)

  48. Scope • Scope is comprised of two parts • Where something can be accessed or called from • aka visibility • How long an item is in existence • aka lifetime • Both variables and procedures have scope • In Visual Basic, scope is determined by: • where a variable or procedure is declared • certain keywords such as Private, Public, Static

  49. Variable Scopes • Procedure-level Variables • Visibility: only available in the procedure where declared • Lifetime: comes into existence when the procedure is called and ceases to exist when the procedure is exited • Module-level Variables • Visibility: anywhere inside the module where declared • Lifetime: the whole time the containing module is loaded • Global-level Variables • Visibility: anywhere, everywhere • Lifetime: the whole time the application is running • Static Variables (procedure-level only) • Visibility: only available in the procedure where declared • Lifetime: the whole time the containing module is loaded

  50. Declaring Variables • Typical variable declaration statement: DimvariableNameAstype • Always declare your variables before using, even though Visual Basic doesn’t require it • Use Option Explicit at the top of all modules –or– • Tools -> Options -> Editor Tab: Require Variable Declaration

More Related