Dim y As Integer y = 10 If y>5 Then y = 1 Else y = 20 End If If y>5 Then y = 100 End IfThe value of y is 1.
Dim x(0 To 10) As IntegerWrite Visual Basic statements to set each element in the array to 100. (Hint: note that the array bounds start at 0!)
Dim i As Integer For i=0 to 10 x(i) = 100 Next i
Dim i As Integer, j As Integer For i=1 to 100 For j=1 to 20 Print "squid" Next j Next i
2000 squids!
Private Sub Form_Click() Dim x As Integer x = 10 Call clam(x) Print x End Sub Private Sub clam(y As Integer) y = y*2 End SubThe output is:
20
Here is a design for a database to keep track of this information. Is this a good design? If not, why not, and what should be done to improve it?
There are three tables: Friends, CDs, and Loans.
Friends has the following fields: FriendID (the key), FirstName, LastName, Phone, and Email.
CDs has the following fields: Artist (the key), Title, and Cost.
Loans has the following fields: LoanID (the key), FirstName, LastName, Artist, and Date. (FirstName and LastName is the first and last name of the friend who borrowed the CD, and Artist is the artist or group who recorded it. Date is when you loaned the CD.)
There are two problems with the design. First, the tuples in the CDs table need to have a unique key -- you might have several CDs recorded by the same artist. So we add a field CDID to the CDs table. Second, the Loans table has redundant information, including FirstName and LastName (redundant with Friends). If we stop using Artist as the key in CDs, the Artist field is also redundant. Replace these fields with FriendID and CDID.