Date: Thu, 29 Jun 2006 14:17:00 -0500 (CDT) From: Mark Jacobson To: 810-030-01@uni.edu Subject: [810-030-01] Study Guide Visual Basic Midterm Exam Friday... Hi Visual Basic students, This will be an outline of some of the main topics for the tests. For your convenience, this note will also be available at the class web page, i.e. at: http://www.cns.uni.edu/~jacobson/c030NET.html 1. Know the P, M, E ideas for Objects... P = Properties Objects have properties Objectname.PropertyName = new value for property lblMessage.Backcolor = Color.Purple for example. M = Methods Objects know how to Do certain things, these things are called Methods... E = Events Object can respond to different Events and execute whatever Visual Basic statements or CODE we have specified. ----- Click is an EVENT that the Button1 OBJECT can respond to. ----- ----- Button1_Click() ----- Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click ListBox1.Items.Clear() CLEAR() METHOD ListBox1.Items.Add("Ghostbusters") ADD() METHOD ListBox1.Items.Add("Dances With Wolves") ListBox1.Items.Add("Wings of Desire by Wim Wenders") ListBox1.BackColor = Color.Tomato .BackColor property ListBox1.Width = 2 * ListBox1.Width .Width property End Sub The Click() event, the Clear() and the Add() methods, and the BackColor and the Width properties. 2. Know the following operators: + - * / \ Mod & = 3. Know how to write a simple For Next loop, with or without a STEP size specified.... Dim theSum As Integer For i = 1 to 10 For i = 100 to 10 Step -10 theSum = theSum + i ... Next i Next i lblSum.Text = "The sum 1 + 2 + ... + 9 + 10 is " & theSum 4. Know how to write a Function. Study the examples of Functions that you have seen in lectures and on handouts. Be able to write a function that accepts arguments (Input), or one that does not require any input. Be able to write a function that has to use an IF statement and/or a For Next loop... Function largest(ByVal num1 As Integer, ByVal num2 As Integer) as Integer If num1 > num2 Then Return num1 Else Return num2 End If End Function 5. Be able to take an array and get the sum of the values stored in it, or find the average. 6. Know how the Selection Sort algorithm works, but you do NOT have to write the code for it. a. How many passes does the Selection Sort make through the data if it consists of 20 items? b. Show what the array looks like after each pass, i.e. after the 1st pass is done, then after the 2nd pass is done, etc. 1 88 ---- 2 17 ---- 3 55 ---- 4 21 ---- 5 12 Show the array after each of the 5 - 1 or 4 passes... ---- ---- 7. Know the Mid() String function. Know how to get the Length of a string. Know the difference between Asc and Chr. Asc comes from ASCII and the ASCII code for "A" is 65, for "Z" is 90, for "a" is 97, for "0" is 48, and for "9" is 57. Chr(32) is " ", i.e. the space Chr(67) is "C", the letter C. 8. Know how to use a Timer and know its two most important properties, and know the name of its Event. 9. Know how to move a PictureBox or a Label across the screen, such as we have done and/or seen with the racing Neko cats or the moving Rectangles... 10. Know how to use an ImageList control and switch back and forth between two running or scratching or sleeping images, to achieve animation effects like in the Neko assignment. 11. Write the code for the btnMakeInitials_Click() event, as described here, using the object names specified below here in the problem description: Given a user interface with three Textboxes named: txtFirstName, txtMiddleName and txtLastName and a Label named lblInitials, write the code to show the initials of the person with periods after each initial, like this: M.F.J. (Mark Francis Jacobson) or J.F.K. (John Fitzgerald Kennedy) or J.L.A. (Jennifer Lynne Aniston) 12. Write the code that the btnClearAll_Click() Sub would contain, so that the user would be ready to type in a new person, starting with the first name, and all previous results and input data would be cleared out and gone. 13. Illustrate the difference between a LargeChange and a SmallChange when using a Vertical Scroll Bar, such as vsbSpeed, for example. Draw a diagram of a vertical scroll bar and show where the LargeChange is used, and where the SmallChange value is used. 14. What are the two most important properties for a Timer control? 15. Know how to declare variables. Know the difference between using Dim and using Static when declaring a LOCAL variable that is inside a Function or a Sub. 16. Review your Ghostbusters multiple choice question. Review the steps of the problem solving/programming process. Review the importance of separating WHAT from HOW. --- You do not have to know the VET SAT AUC TVV SO YMDC phrase... --- VET = Very Effective Thinking VETeran SAT = So As To SAT down AUC = Avoid Unmastered Complexity to watch AUC (All My Children) All U Children) TVV = To Very Vigorous on TVV SO = Separation Of while SO (Staying Over) YMDC = Your Many Different Concerns at the YMDC (YMCA in Washington DC) There is no better quote that I know of for describing computer programming and software development than the VET SO AUC TVV SO YMDC phrase from Dijkstra. Programming bois down to nothing more and nothing less than... "... very effective thinking so as to avoid unmastered complexity, to very vigorous separation of your many different concerns." VET SO AUC TVV SO YMDC ---------------------- Just for fun, a couple of other Dijkstra quotes... "If in physics there's something you don't understand, you can always hide behind the uncharted depths of nature. You can always blame God. You didn't make it so complex yourself. But if your program doesn't work, there is no one to hide behind. You cannot hide behind an obstinate nature. If it doesn't work, you've messed up." "It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration." http://en.wikipedia.org/wiki/Edsger_W._Dijkstra See you tommorrow at the test. If you are turning in your program later today, turn it in under the door of Wright 117 (or Wright 117A cubicle if the outer door is open). I work alot up in Wright 338A too, for my statistical consulting lab job. That is where I have Visual Basic Express edition installed too. My 117A office machine has only Visual Basic 6.0 installed. ---------------------------------------------------------------------- We will NOT have class on Monday, July 3rd, as the class has gone over 60 minutes to 65 or 70 minutes enough times to make up for one class. So have a happy FOUR DAY FOURTH OF JULY weekend and holiday after you get the exam behind you. ---------------------------------------------------------------------- Mark