0% found this document useful (0 votes)
24 views4 pages

Visual Programming 2020

The document is an examination paper for the Bachelor of Science (General) Degree at the University of Ruhuna, specifically for the Visual Programming course. It includes a series of programming tasks and questions related to Visual Basic, covering topics such as GUI design, error types, array manipulation, and event handling. Students are required to write code segments and subroutines to demonstrate their understanding of the concepts taught in the course.

Uploaded by

krwuor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views4 pages

Visual Programming 2020

The document is an examination paper for the Bachelor of Science (General) Degree at the University of Ruhuna, specifically for the Visual Programming course. It includes a series of programming tasks and questions related to Visual Basic, covering topics such as GUI design, error types, array manipulation, and event handling. Students are required to write code segments and subroutines to demonstrate their understanding of the concepts taught in the course.

Uploaded by

krwuor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Kasun Ranga Wijeweera (krw19870829@gmail.

com)

UNIVERSITY OF RUHUNA

BACHELOR OF SCIENCE (GENERAL) DEGREE

LEVEL III (SEMESTER II) EXAMINATION – JANUARY 2022

COURSE UNIT: COM323α – Visual Programming Duration: 2 hours


___________________________________________________________________________
Answer four (4) questions only

1)
a) Write Visual Basic code segments to perform the following tasks.

i. There is a checkbox named as CheckBox1 on a form. The texts “Checked” or


“Unchecked” should be displayed on the title bar of the form depending on
whether the checkbox is checked or unchecked respectively.

ii. There is a combo box named as ComboBox1 that already contains a collection
of integers. The square of the integer selected from the combo box should be
displayed in a message box.

b) Write Visual Basic subroutines to perform the following tasks.

i. There is a button named as Button1. The button initially displays the integer “1”
on it. The integer on the button should be incremented by 1 per each click on the
button.

ii. There is a label named as Label1. The text of the label should be changed to
upper case when the mouse pointer is moved over the label.

iii. There is a list box named as ListBox1 on a form. The number of the total clicks
on the form should be added to the list box per each click.

2)
a) Find the final values of variables x and y after executing the Visual Basic code
segment given below. Show each step clearly.

Dim x As Integer = 4
Dim y As Integer = -3
Do Until x < 1
x=x+y
Do While y < -2
y=x+y
Loop
Loop

1 of 4
Kasun Ranga Wijeweera (krw19870829@[Link])

b) Suppose tea leaves can be divided into three categories: A, B, and C based on a
quality test. Table 1 shows how the category is decided based on a value (t1)
measured in the test.

t1 Category
t1 < 30 A
30 ≤ t1 < 70 B
70 ≤ t1 C
Table 1

These categories can further be divided into subcategories based on another


quality test. Table 2 shows how the categories are subdivided based on a value (t2)
measured in the second test.

t2 Subcategory
t2 < 20 A1
20 ≤ t2 A2
t2 < 50 B1
50 ≤ t2 B2
t2 < 80 C1
80 ≤ t2 C2
Table 2

i. Draw the design of a suitable Graphical User Interface (GUI) for a tea leaves
categorization system to decide the subcategory based on the values derived
from the given two quality tests. Identify the GUI controls of the design.

ii. Write a Visual Basic code segment for the design given in (2) (b) (i) using If
Then Else statements. Use appropriate names for the GUI controls.

3)
a) State the three types of errors in computer programming and describe those by using
suitable Visual Basic examples.

b) Write Visual Basic code segments to perform the following tasks.

i. Declare a two dimensional integer array without specifying the size.

ii. Set the size of the array declared in (3) (b) (i) to 2 × 3.

iii. Initialize the elements in the array declared in (3) (b) (ii) with numbers shown
in the grid given below that corresponds to the array.

0 1 2
0 7 6 3
1 4 5 2

iv. Replace each value by its squared value in the array created in (3) (b) (iii) by
using nested For loops.

v. Compute the sum of the values in the array created in (3) (b) (iv) and display the
result in a message box.

2 of 4
Kasun Ranga Wijeweera (krw19870829@[Link])

4)
a) Suppose that there are three combo boxes named as ComboBox1, ComboBox2, and
ComboBox3 on a form. The user can input year, month, and day respectively
through these combo boxes. Additionally, there is a button named as Button1 on the
form. Write Visual Basic code segments with subroutines to perform the following
tasks.

i. Integers from 1900 to 2100 should be added to ComboBox1 when the application
is started.

ii. Integers from 1 to 12 should be added to ComboBox2 when an item is selected


from ComboBox1.

iii. Integers from 1 to n should be added to ComboBox3 when an item is selected


from ComboBox2 according to Table 3 given below.

Selected Item Value of n


1 31
2 29
3 31
4 30
5 31
6 30
7 31
8 31
9 30
10 31
11 30
12 31
Table 3

iv. The date specified using the combo boxes should be displayed in a message box
when Button1 is clicked.

3 of 4
Kasun Ranga Wijeweera (krw19870829@[Link])

5)
a) Suppose that there are three list boxes named as ListBox1, ListBox2, and ListBox3
on a form.

• The selected item in ListBox2 should be added to ListBox1 when left mouse click
is performed on the form.

• The selected item in ListBox2 should be added to ListBox3 when right mouse
click is performed on the form.

Write a Visual Basic code segment with subroutines for the above scenario. Note
that the exceptions should be handled carefully.

b) Suppose that there is a panel on a form named as Panel1. Write Visual Basic code
segments with subroutines to perform the following tasks.

i. Set the properties of Panel1 as given in Table 4 when the application is started.
The Properties window should not be used.

Property Value
BackColor Silver
BorderStyle FixedSingle
Table 4

ii. The x-coordinate of the mouse pointer should be displayed in a message box
when the left mouse button is pressed and the y-coordinate of the mouse pointer
should be displayed in a message box when the right mouse button is pressed.

iii. The background color of Panel1 should be changed to “Black” when the mouse
pointer enters the panel and changed back to “Silver” when the mouse pointer
leaves the panel.

4 of 4

You might also like