NCC Education International Diploma IN Computer Studies Visual Basic December 2009 - Local Examination
NCC Education International Diploma IN Computer Studies Visual Basic December 2009 - Local Examination
Time: 2 hours
Clearly cross out surplus answers. Failure to do this in Section B will result in only the first two answers being marked.
Any reference material brought into the examination room must be handed to the invigilator before the start of the examination.
Visual Basic
December 2009
Final
QUESTION 2 The diagram below shows a trapezium: a h b The area of a trapezium can be calculated by summing the lengths of side a and side b and then multiplying this sum by the length of side h. The following program has been written to implement the above rules. Public Sub Main Dim a As Integer Dim b As Integer Dim h As Integer Dim area As Integer a=1 b=2 h = 10 area = a + b * 0.5 * h End Sub State the value of area calculated by the above procedure. Comment on this value.
QUESTION 3 In a program the variables a, b and c are declared as integers. This program assigns the value of c as follows: c=a/b State why this may generate an error and describe how you could modify the code to deal with the error.
Marks QUESTION 4 A program that calculates the stress in the cables holding up a suspension bridge uses the area of the cables 4 within the calculation. There are many different sizes of cables, all of circular cross-section. Explain how you would include the area calculation in your program.
QUESTION 5 State TWO (2) reasons for your answer to question 4 above.
QUESTION 6 Explain what an event-driven program is. Give an example to illustrate your answer.
QUESTION 7 Name FOUR (4) types of application that can be developed using Visual Basic 2005.
QUESTION 8 Name FOUR (4) relational operators in Visual Basic 2005 and give their symbols.
QUESTION 9
The Access table above contains the personal particulars of each programmer working in the company called Eminent Programmers. When you search for a programmer with the first name of Charles and the last name of Richter, you found that two records were returned because there are two programmers with the same name. Briefly describe what you can do to the design of this table so that each programmer working in Eminent Programmers can be uniquely identified. State the component of the Framework Class Library that allows a Visual Basic 2005 program to access data contained in Access tables.
QUESTION 10 State the type of output produced when a Visual Basic 2005 program is compiled. Briefly describe what 4 happens when such output is executed. Total 40 Marks
The name of the above form and its controls are as follows: Name of form: frmCustRecs Name of button: btnToggleCustName Name of label: lblCustName Name of textbox: txtCustName
a) b)
Describe how you would set the text displayed in the title bar of the form to Customer Records. The form has 2 states: When the short name stored in the string strShortName is displayed in the textbox the label displays Customer Short Name and the button displays Toggle to Full Name. When the full name stored in the string strFullName is displayed in the textbox the label displays Customer Full Name and the button displays Toggle to Short Name. Clicking the button toggles between these two states. Write the body of the event handler for the button click event.
9 10
c) d)
State the event to handle in order to have the short name displayed in the txtCustName textbox when the application is first launched. State the name of the object to which this event belongs.
An event planning document is useful for capturing the processing of events for an application/form. 7 State the THREE (3) components/columns of this document. Document the event processing for the btnToggleCustName button in this document. Total 30 Marks
Marks
SendMessage function procedure: Function signature Public Function SendMessage(ByVal pMessage As String, ByVal pAddress As Integer, ByVal pProgramID As Integer) As Boolean Purpose This function will send out a user-configured String message contained inside pMessage to a device identified by pAddress and a recipient program on that device identified by pProgramID. Arguments The 1st argument (pMessage) will hold the message to be sent, The 2nd argument (pAddress) will hold the address of the recipient device, and The 3rd argument (pProgramID) will hold the ID of the recipient program Return Value When a message is successfully sent, the function will return a True value, otherwise, a False value will be returned. CheckForReply function procedure: Function signature Public Function CheckForReply(ByVal pAddress As Integer, ByVal pProgramID As Integer) As Boolean Purpose This function will check for a reply from the program to which a message was earlier sent. The program and its hosting device to which a message was earlier sent are identified by pProgramID and pAddress respectively. The reply from this program is a simple acknowledgement and will not be further processed. Your program can tell whether a reply was received by checking the value returned by this function. Arguments The 1st argument (pAddress) will hold the address of the device that your program is checking for a reply, and The 2nd argument (pProgramID) will hold the ID of the program that generates this reply Return Value When a reply is found received, this function will return a True value, otherwise, a False value will be returned. a) Write code to send a message Good Morning to a device identified by the address 10 with a recipient program identified by the ID 1. If the message is not successfully sent, display a message Message not sent, please try again in a message box. 10
b)
c)
If the message is successfully sent, your program will check for a reply from the recipient program by making call(s) to the CheckForReply function up to a maximum of 5 times. If a reply is still not found to be received on the 5th attempt, the message Message sent but reply is not received should be displayed in a message box. Total 30 Marks
QUESTIONS CONTINUE ON NEXT PAGE Page 5 of 6
Visual Basic
December 2009
Final
QUESTION 3 a)
Marks 10
You are writing a Visual Basic 2005 program to create a series of values to be stored in an array. The first value of this series will be 2 and will be placed into the first element of your array. Each subsequent value will be arrived at by multiplying the previous value by 3. For example, the first 4 values of this series will be 2, 6, 18 and 54. Create an array to store the first 10 values of this series. Note: You are not allowed (except for the first value) to hard-code the values of this series into the array elements.
b)
Now rewrite your answer to part a) as a function. This function will allow the creation of an array containing a series of values like that of part a) but which allows the user to set the value of the first term, the multiplier and the number of values in the array. This function will return the fully populated array. Note: You are supposed to declare and define the function procedure rather than making a call to such a function.
20
Total 30 Marks
END OF PAPER
Page 6 of 6
Visual Basic December 2009 Final NCC Education Ltd 2009