Visual Basic 4 in 12 Easy Lessons Answers (All Units) Lesson 1, Unit 1 1. A program is a list of instructions that tells the computer exactly what to do. 2. Absolutely nothing. A computer is a dumb machine that cannot function without the detailed instructions of a program. 3. You can buy a program or write one yourself. 4. The programs that you write do exactly what you want them to do once you get any bugs out of them. 5. Writing your own programs takes lots of time and effort. 6. True 7. Code is a program. 8. An error that you accidentally place in the programs that you write. 9. There are syntax errors and logic errors. 10. You've just put a syntax error in the program. 11. Visual Basic finds syntax errors for you. 12. Logic errors are much harder to find than syntax errors. 13. With hardwired control panels. 14. Non-electrical people could program computers. 15. On and off states of electricity. 16. The addition of the computer keyboard introduced programming to the masses. 17. Code is the program that you and other programmers create. 18. Machine language 19. FORTRAN 20. BASIC 21. Beginner's All-purpose Symbolic Instruction Code 22. Procedural programming languages lend themselves well to text-based DOS environments. 23. Event-driven programs lend themselves well to Windows-like environments. 24. Graphical User Interface 25. Two events might be a keypress or a mouse click. 26. The user might trigger any event in any order. 27. False. Visual Basic does require some procedural-like programming for certain functions. 28. True Lesson 1, Unit 2 1. True 2. True 3. You need approximately 18 megabytes of free disk space to install the Visual Basic Working Model. 4. False 5. Click your Start button, choose Run, and type D:\CDSETUP (You can type the command in uppercase or lowercase letters). If your CD-ROM is not drive D, substitute the proper letter. For example, if it's actually drive G, you would type G:\CDSETUP. 6. The value used if you don't type a different value. 7. C:\Program Files\Microsoft Visual Basic 8. Select File Exit to exit Visual Basic and return to Windows. 9. You may lose some or all of the program you're writing. 10. The Code window, Form window, Project window, Properties window, and the Toolbox window. 11. Visual Basic uses the Form window for the application's background. 12. False 13. True. Double-click the toolbox's upper-left corner. 14. Use the shortcut keys to execute menu commands more quickly. 15. The toolbar provides push button access to common menu commands. 16. The Visual Basic menu bar follows the same naming standard for most of its menu commands as other major Windows programs use. 17. Twelve 18. Not all menu or toolbar commands are available at all times. 19. A tooltip is a floating description that appears when you hold your mouse over a toolbar button. 20. The measurement indicators describe the size and location of elements on the Form window. 21. A twip is 1/1440th of an inch. 22. The grid provides snap-to locations that keep controls in alignment with the grid's dots when you set the appropriate Tools Options command. 23. F1 24. Index locates topics based on a keyword that you specify whereas Find searches through all the help text looking for every occurrence of a word or phrase you want to find. Lesson 2, Unit 3 1. You must first use the File Open menu to load the application. 2. The project file holds the application's description. 3. .VBP (older Visual Basic project files use the .MAK extension). 4. Load the project and look in the Project window. 5. So that the user can interact with and direct the program. Users click, scroll, and manage the controls as a way to respond to a program's activities. 6. The Toolbox window holds the controls that you can add to your form. (Don't you think "Control window" would be a better name?) 7. The user needs an easy way to exit a program. 8. False. The user cannot directly change text displayed in a label control. 9. The text box control. 10. You can control the font size and style of the text. 11. The user can move the text cursor forward and backward in a text box as well as use the Ins and Del keys to insert and delete text. 12. The command button control 13. False 14. True 15. The user deselects a check box by selecting the box a second time. 16. The frame control 17. True 18. True 19. False 20. True as long as the Visual Basic programmer designed the list box so that the user can make multiple selections. 21. The form works as the application's background and holds the controls that you place there. 22. True 23. The user can click the command button with the mouse or press the Alt+ shortcut keystroke if the command button's label contains an underlined character. There is a third way as well (not documented in this unit): The user can press Tab until the command button is highlighted and press Enter. 24. The command button next to the combo box informs Visual Basic that there is data to be added to the list. 25. Pamela should replace the simple combo box with a dropdown combo box control. Lesson 2, Unit 4 1. An event might be a user keypress, mouse movement, mouse click, menu selection, or virtually anything else that a user can do to respond to a program. 2. There are too many ways for the user to interact with the visual controls on the screen. A text-based program dictates the order of the user's involvement. 3. False. Sometimes Windows captures events for its own system use. 4. Properties are attributes that differentiate the actions and behaviors of controls. 5. Event procedures 6. Here are four properties (from a huge list of many others): font size, font style, the control size, and the control color 7. True 8. True 9. The Properties window 10. The process of updating the program later. 11. The three-letter prefix describes what kind of control you're working with. 12. Users of your programs will more speedily adapt to the programs when they follow Windows standards. 13. AUTOLOAD.MAK 14. CONSTANT.TXT 15. Names given to data values that make them easier to remember. 16. False 17. Double-click the control on the Form window. 18. The first part of the event procedure is the control name, followed by an underscore, followed by the name of the event (and parentheses come after that to let you know you're working with a procedure name and not a control name). 19. Wrapper code 20. End 21. The controls and form names inside the project. 22. Usually the project and form names are the same with a .MAK and a .FRM extension respectively. 23. A form 24. A combo box 25. A command button 26. Victor, less is better! Use fewer fonts or you'll confuse the user looking at your screen. 27. A. End is a reserved word. B. Names cannot begin with a number. C. Names cannot contain special characters such as dollar signs. D. Names cannot contain hyphens. Lesson 3, Unit 5 1. The control that has Window’s current attention. You can tell which one it is by the highlighting. 2. The order in which the controls receive the focus as the user presses the Tab key. 3. TabIndex 4. The Name property. 5. False 6. True 7. No but when you set the label's UseMnemonic property, the control that follows the label, such as a text box, will receive the focus when you press the shortcut keystroke for the label. 8. An icon is a picture. 9. A point is 1/72nd of an inch. 10. A selection of colors from which you can choose. 11. D. — All of the above. 12. Enabled. 13. 0, 1, or 2 representing left-justified, centered, or right-justified. 14. False. Rarely will you have to set or change more than a few properties because the default values are so common for many of the properties. 15. A carriage return character sends the text cursor to the next line on the screen. 16. Dynamic Data Exchange. 17. True due to the Visible property. 18. Left, Right, Top, Width. 19. The label control. 20. The PasswordChar property. 21. The Cancel property. 22. Use the control dropdown selection box. Lesson 3, Unit 6 1. Yes, the form is an object as are the other controls. 2. False, label controls have no MultiLine property. 3. A pixel is the smallest screen element available. 4. The WindowState property. 5. Chopping off part of text. 6. False 7. False, only text box controls can have scroll bars. 8. Set the AutoSize property to False. 9. True. 10. False. 11. The TabIndex property controls the focus order. 12. The Load event. 13. The Load event occurs before the Activate event occurs. 14. The Code window contains a Proc dropdown list box that contains all the events for any given object. 15. Labels can never receive the focus. 16. The name of the event procedure must be txtLastName_Change(). 17. The KeyPreview property determines whether the form or control gets the keystrokes. 18. The Caption property. 19. Add the access key to a label that describes the text box contents. Make sure that the TabIndex of the label is sequentially one less than the TabIndex of the text box. 20. The labels could hide too many other form objects. 21. The label would automatically expand horizontally before you have a chance to set the WordWrap property. Lesson 4, Unit 7 1. A named storage location in memory. 2. The Dim statement. 3. A data type is a category of data that all Visual Basic values fall into. 4. Integer, Long, Single, Double, Currency, Variant, String 5. Integer 6. Double 7. Single, Double, and Currency 8. E means Exponent. 9. Scientific notation provides a shortcut notation for a wide range of numeric values. 10. False 11. True. Variables can change but they do not have to. 12. You'll help eliminate bugs that can occur when you misspell a variable name. 13. A fixed-length string can only accept a preset number of characters whereas variable-length strings can accept strings of changing-length as a program runs. 14. True 15. True 16.A.7 B.9 C.16 D.40 (parentheses would be required around the addition to compute a true average) E.2 F.40 17. Merge the strings together 18. + is used for either addition or string concatenation (depending on the context of its use) and & is used strictly for concatenation. 19. Dim SqFoot As Single 20. SalesPrice = Price / Discount Tax = TaxRate * SalesPrice 21. Name is a reserved word and cannot be a variable name. 22. Judy cannot define more than one variable with the same name. There is an advanced exception to this rule that you'll learn in Lesson 7. 23. Larry cannot use a dollar sign or commas in constant values.