Visual Basic questions
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?
3. Name the two properties that have to be set in order that a ComboBox or a TextBox
be a data aware object?
4. Your form must contain a different data control for every table in the database
that you want to get field data from.
T or F
5. What is the difference between a record and a field?
6. Name the three possible values that the RecordSetType property of the Data
control can have.
7. What Data control property can take a SQL statement as its value at Design time
or at Run time?
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. 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. Write the Visual Basic statement to make the pixel at row 2, column 4 of the
Picture1 control identical to the pixel at the very lower right-hand corner of
the Picture1control. It is the row 2, column 4 pixel that is changed to a new
color, the color of the lower-right-hand pixel. The pixel in the bottom right
corner of the Picture1 control will be unchanged after the statement finishes.
The pixel at row 2, column 4 will be a different color. The control name is
Picture1.
5. Write the Visual Basic statement to set the pixel located in the 1st row and the
4th column of the Picture1 control to a perfect BLUE in color. By the 1st row,
the very top row of the entire Picture Box control named Picture1 is referred to.
6. What does the following code do? Describe the result of the statement carefully.
Image1.Move Image1.Left + 50, Form1.ScaleHeight / 2
7. Use the _______________________ method of a recordset to rebuild the
recordset when you want to change to a new set of records during runtime.
8. The RecordSource property of thedata control is used to specify the information
to be used when creating the RecordSet object. What are the three types of
information that can be used in the RecordSource property of the data control?
9. What are the names of the two properties that you set for every bound control so
that it automatically displays the desired information from a database your form
is connected to?
10. Write the Visual Basic statement to cause a line to be drawn from the upper
left-hand corner of the Form to the lower right-hand corner of the form.
11. What is wrong with the following Visual Basic procedure header line?
Private Sub Form1_Load()