CS508
Programming Assignments
revised September 7, 2000


   
Not accepted after
Submitted
Returned
Credit
1. Write a Visual Basic program consisting of just a single form that prints messages on the form telling when the following events occur: Activate, Click, DoubleClick, Resize, MouseUp, MouseDown, KeyDown, KeyUp, KeyPress Form events
 
     
2. Construct a form containing seven image controls of different sizes (as shown on pages 118 and 119 of the textbook) and a textbox (see pages 119-122).  Fill your image controls with icons found in the traffic icons directory that ships with Visual Basic.  The textbox should have its Multiline property set to true, have a vertical scrollbar, and contain so much text that the text is not all visible in the text box at one time.  Objects on a form
 
     
3. Write a Visual Basic program to convert temperatures from Fahrenheit to Celsius and from Celsius to Fahrenheit.  The form should have two text boxes, one each for  the user to enter each form of temperature, and two buttons for conversion.  Also, the form should have an additional textbox, called txtIncrement, and two buttons, called cmdIncrementFahrenheit and cmdIncrementCelcius that will allow the user to step through various values of the temperatures and obtain conversions of them.  The command button to convert from F to C should be enabled only when some F temperature is entered.  The command button to convert from C to F should be enabled only when some C temperature is entered.  The button cmdIncrementFahrenheit should be enabled only when an F temperature and an increment are entered.  The button cmdIncrementCelsius should be enabled only when a C temperature and an increment are entered.  At all times, some button or another should be the default button.  All buttons and text boxes should have access keys. Temperature conversions with incrementing
 
     
4. Improve the temperature converter by having your program display a table of temperatures and their converted values.  Allow the user to specify the beginning and end values for the table, and the table increment.  Prevent the user from crashing your program by entering an increment of 0. Temperature converter with table        
5. Modify Assignment 4 to make the table form sizable by the user (but not maximizable).  Keep the table horizontally centered.  Keep the command button the same distance from the bottom of the form that it had at design time and horizontally centered.  Adjust the height of the table appropriately.  Do not allow the user to make the form so small as to crash the program.  Use the Form_QueryUnload event to prevent the user closing the form with the exit button or the control menu (optional). Sizable table        
6. Write a program that allows the user to select a state name and a category (flower, nickname, or motto), and that shows the flower, nickname, or motto for that state. Use option buttons for the category and a list box for the names of the states.  During Form_Activate, read data for 10 states from the file states.txt to fill the list box and arrays for flowers, nicknames, and mottos.  Use the AddItem method to fill the list box.  Include also a check box that allows the user to request that the response be in the form of a full sentence. State names and categories        
7. Write a program to allow the user to request a positive, non-zero number of labels (up to a maximum of 30), and then create that number of labels in a square or nearly square array.  Labels should have a white background, a fixed border, and a caption that shows the number of the label (starting with 0).  Allow the user to drag and drop any label anywhere, except that the label cannot be dropped on any other control or on any other label.  If the user holds down the Ctrl, Alt, and/or Shift keys, change the background color of the label during the drag operation and restore the background to white when the label is dropped.  Use the following colors: Ctrl only, black; Alt only, blue; Shift only, green; Ctrl-Alt, cyan; Shift-Alt, Red; Shift-Ctrl, magenta; Shift-Alt-Ctrl, Yellow.  Place a drag icon such as DROP1PG.ICO into your project and use it to indicate when the label is being dragged.  Show the icon when the Drag method is given and before the mouse moves.  Show the MousePointer as vbNoDrop during a drag operation when the mouse is over a control other than the label being dragged. Dragging labels        
8a. Read about the Clipboard (pgs. 747-752) and fix your Edit menu so that mnuEditCut, mnuEditCopy, mnuEditPaste, mnuEditDelete, and mnuEditSelectAll work according to Windows conventions.  The conventions are:
  • If some text is selected, Cut and Copy should be enabled
  • If no text is selected, Cut and Copy should be disabled
  • If there is text in the clipboard, Paste should be enabled
  • If there is no text in the clipboard, Paste should be disabled
  • Select all should always be enabled
  • Delete should always be enabled.  If some text is selected, Delete should delete it. If no text is selected, Delete should delete the character to the right of the insertion point.
Edit menu        
8b. Fix the print dialog box so that the Selection button is disabled, no Print to file check box is presented, and so that you can Exit Sub when the user clicks the Cancel button.  Search in Help on the CancelError property, the On Error statement, and the Err object. Print dialog