SABATIA TVC
VISUAL PROGRAMMING
COURSE: DIPLOMA ICT TIME: 2HRS
INSTRUCTIONS: Answer question one and any other two questions
Question One (30 marks)
a. State Object naming conversions of controls (prefix) for the following
i. Textbox
ii. Command button
iii. Form
iv. CheckBox
v. comboBox (5 marks)
b. Explain four data types found in visual basic programming (4 marks)
c. With aid of an example show how constants are declared in visual basic. (2marks)
d. Differentiate between public variable and local variable (4 marks)
e. Write a Visual Basic program that will compute the average of integers from 20 to 50 and
output the result on a form. Use for loop. Attach the code to a command click event.
(3 marks)
f. Table 1 shows the status of two expressions after execution in Visual Basic programming
language. Use it to answer the question that follows:
Table 1
Expression1 Expression2 OR AND
False False
False True
True False
True True
Evaluate the effect of combing the two expressions through the use of logical operators
OR and AND. (4 marks)
Page 1 of 3
g. Distinguish between the following as used in Visual Basic programming language:
(8marks)
i) DirListBox and FileListBox
ii) Data and OLE iii)
PictureBox and Frame iv)
Method and Event
Question TWO (20 marks)
a) Explain the meaning of the following text box properties (6 marks)
i) SelLength ii) SelStart iii) SelText
b) Distinguish between the following as used in visual basic programming language.
i) Label and command button
ii) ListBox and ComboBox
iii) checkbox and Option button (6 marks)
c) Using visual basic arithmetic operator give the results after evaluation in table1 (8marks)
Table 1
Operand and operator Results
5+5
10-5
25/5
20\3
5*4
3^3
20 Mod 6
Page 2 of 3
"George"&" "&"Bush"
Question Three (20 marks)
a) Write a code to add the following Nairobi, Nyeri, Embu, Muranga, Nyandarua and
Kiambu county in a combo box. (6 marks)
b) Assume you have to find the grade attained by a student for a course unit done in a given
semester using nested if write a code that will display the grade in a text box. Use table 2
to assign grades. (10 marks)
Average Grade
Above 70 A
Above 60 B
Above 50 C
Above 40 D
Below 40 E
c) Write the syntax of the Select…Case structure (4 marks)
Question Four (20 marks)
a) Distinguish between the Str () and Chr() functions as used in Visual Basic
programming language. (4 marks)
b) With the aid of a program flowchart, describe the following control structures as used
in programming languages:
i. Sequence;
ii. Selection. (6 marks)
c) Write a Visual Basic program that will be able to count from 1 to 50 and display the
output in a form. Use a Do While...Loop. Attach the code to a command click event.
(4 marks)
d) Explain the function of each of the following components in a Visual Basic
programming language:
i. Project Explorer Window
ii. Toolbox
iii. Object browser (6 marks)
Page 3 of 3