Midterm exam on Tuesday, July 10th, 2001 For sure, you should be studying all the lecture notes and handouts from the class, as well as the related readings from the book. The Timer control has been seen many times. The RGB function for generating a color should be understood very well at this point in the class. How to use the Rnd function to get whatever random numbers you want should be well understood. The names of the main properties we have used for Labels, Command button, Image and PictureBox controls, TextBox controls, Timers, vertical scroll bars, and List Boxes would be important. The LoadPicture() function that can be used for Image and PictureBox controls is vip. Here are a couple of sample questions: 1. The user is to see a message box that displays the message HELLO WORLD! when they click anywhere on the Image1 imgSeeMessageBox control. Write the code so they see the message box (with the standard OK button) after they click on Image control imgSeeMessageBox. 2. Write the statement to erase the drawing that has happened on Picture1 picture control: 3. Write the entire event procedure that would make the gif file JEWEL.GIF be displayed in the control imgMusicians. The Image control imgMusicians will display this when you click the command button cmdDisplayJewel. The path to get to the JEWEL.GIF file is A:\JEWEL.GIF, since we will assume it is on a diskette. 4. Carefully describe what the very 1st thing is that thefollowing Visual Basic statement does or causes the computer CPU to do or perform? (The statement consists of 5 different steps or operations). whichPt = Int(Rnd() * 3 + 1) Can you write the above statement as 5 separate statements? It really does consist of FIVE different operations by the computer. You would need to use extra variables to show it as 5 separate statements on 5 lines. 5. What is the 2nd action that occurs during the CPU's execution of the above Visual Basic statement? Describe it carefully and precisely. 6. What are the main two properties of a Timer control that a programmer needs to use the most often? (Answer with the NAME of each property). 30. Write the event procedure for a Timer named Timer1 so that it changes the lblPanthers background color to a randomly chosen color (one of 16 million) every 1/2 second. Write the entire event procedure, not just the statements that would go inside of it. You can assume that Timer1 is already set to 1/2 second at Design time. 31. Write a command button event for the button called cmdPauseResume so that it would cause the Timer1 to stop if it was going and to start again (RESUME) if it was paused. The message on your command button should say Pause if the color changing is running and it should say Resume if it is currently paused. (This exercise relates to item 30, shown above here). 81. Write the Visual Basic statement that would change the color of the letters (not the background color) and characters displayed in the Label control named lblQuestion81 to the brightest RED possible. Use the function we have used in class and examples over and over and over again to do this. Do NOT use any constants (there is one called vbRed). 82. Know the idea of STATIC variables. 83. Know how to do a FOR NEXT loop to print the numbers 1 through 10 on a FORM or on a PICTUREBOX control. 26. What does the following statement do? Explain carefully. PSet (100, 200), RGB(0, 0, 255) 27. What property determines the size of the graphic that the above question 26 statement would cause? 27. What property determines the color of the graphic that the above question 26 statement would cause? 1. Write the code so that the match (the fire image) causes the Image6 icon to be displayed in the Image1 control instead of its currently displayed icon. Your code should change the dropped object (no matter what it was) to be invisible after the DragDrop event has happened. The match has fire as its Tag value. Private Sub Image1_DragDrop(Source As Control, X As Single, Y As Single) End Sub 2. Consider the following Visual Basic procedure and answer the following set of questions about it. Private Sub Form_Resize() With Form1 .Cls ' see this line for Question#3 .CurrentX = .ScaleWidth / 2 .CurrentY = .ScaleHeight / 2 End With Print "X" End Sub (a) When will this procedure be executed? Carefully describe and list all of the possible events that will cause it to execute. (b) What exactly does the procedure do? Be specific in your description. (c) What happens when you delete or comment out the .Cls line of the Form_Resize event procedure? (d) What is the purpose of the With and End With statements in the above program? 8. Suppose you have a menu that is named mnuChangeImage and you want it to be a context-sensitive menu and show up when the user right-clicks the mouse on the imgPhotoFrame image control. a. What event procedure needs to be programmed. What will it be named? b. Write the code that the event procedure will contain, so that the menu mnuChangeImage is displayed when the user of your program right-clicks on the imgPhotFrame image control. 9. Suppose the ListBox control is called lstMovieRentals. Give the Visual Basic statement to place the movie "Steel Magnolias" into the lstMovieRentals control. 0. How many different settings or values are there for the MultiSelect property for a ListBox control? 1. The default Visual Basic ScaleMode is: 2. What are the properties for a vertical scroll bar control that you would need to set at Design time or at Run time for a program such as the dancing U N I program to work. Recall the name of the scroll bar was vsbSpeed in our animated dancing U N I program. 3. The string functions, such at Left and Right and Mid and Len and UCase. Left("Ghostbusters", 5) Right("Panthers", 4) Mid("Ghostbusters", 6, 3) Len("How long is this string?") UCase("Now aLL 28 LeTTers will be UPPER case")