Expert Answers

A. Given a large array named intAgeArray, use a loop to set the value of each element in the array to the value of the subscript (index) of the element. For example, if the first element is set to the value 0, the second element would be set to the value 1, and so on.

B. Write a Visual Basic statement to sort the elements in the inAgeArray.

You recently found a job as a sales rep for a company that has customers in three states. The job involves a lot of travel in your car. Fortunately, the company reimburses you for the miles you put on your car. Instead of using a spiral-bound notebook to record your trip data, you decide to build an application for your laptop to keep track of your trips. Assume that you have already built the form, that you have written the code for the button-click event handler, and all you have left to do is define a class. Define a Trip class to store the beginning and the ending odometer readings for the trip. You will also want to store the destination and the date. Store the odometer readings as numbers and the destinations and dates as strings. Be sure to restrict access to these variables to methods that belong to the class.

At this time, the only method you need to define for your class is a method to create a message box to display the destination, the miles traveled, and the trip date. Set the caption of the message box to the destination and the date. Each item should be displayed on a separate line. For example, the message box for a member’s item could look like the following.

Destination: Eugene
Mileage: 456
Trip Date: 10/30/2010

A. You are asked to create a form with a textbox named txtLocation, a label named lblGolfClub, and a button named btnGetGolfClub. In the space below, write the Visual Basic code to be placed in the button-click event handler. Your code will retrieve the location on the golf course entered by the user. If the location is the green, the user will need the putter. If the location is the tee, the user will need a wood. At any other location, the user will need an iron. After your code declares variables and retrieves the location value entered in the textbox by the user, create a three-alternative selection statement that
• sets a string named strGolfClub to “putter” if the location value entered by the user is “green;”
• sets a string named strGolfClub to “wood” if the location value entered by the user is “tee;” and
• sets a string named strGolfClub to “iron” if neither of the conditions above is true.
The last step is to display the golf-club string in the label.

B. What will be the Handles clause at the end of the sub procedure?

You have a friend who lives near the Canadian border and makes road signs. He is often asked to make signs that specify distance in miles and kilometers. His boss gives him only the number of miles, and he must convert miles to kilometers. When he complains about using a calculator for the conversion, you tell him that, because you completed BIS311, you are confident that you can build an application to help him. Your application will input the number of miles, calculate the number of kilometers, and then display the number of kilometers. You will use a constant to store the miles-to-kilometers conversion factor.

A. In the space given below, list each control element that your form will need. Provide the following information about each control element, separated by commas:
the Control type, the control’s Name property (using a naming convention), and the event.

Note: your answer will be more readable if you separate each control element with a blank line.

B. Declare each variable and constant that the form’s event handler sub procedure will need. The miles-to-kilometer conversion factor is 1.609344. Assume that all values will have a fractional part.
You do not need to do any calculations. Use an appropriate naming convention in your answer.