visual programming
visual programming
REG: DCS/2022/36138
a.) Code Editor: is where developers write and edit their Visual Basic code. It provides features
such as syntax highlighting, code completion, and error checking to aid in writing efficient and
error-free code. It's the central workspace where developers spend most of their time crafting
their applications. It simplifies the process of creating visually appealing and interactive user
interfaces.
b.) Form designer: It allows developers to design the graphical user interface (GUI) of their
applications visually. Developers can drag and drop various controls such as buttons, text boxes,
labels, etc., onto the form and then customize their properties and layout using the properties
window and layout tools. This component enables developers to create visually appealing and
functional interfaces without writing extensive code manually.
c.) Project Explorer: The Project Explorer provides an organized view of the project's structure,
including forms, modules, classes, and other resources. It allows developers to navigate through
different components of their project, manage files, and access properties and events associated
with each item. The Project Explorer is essential for managing and organizing project files and
facilitates efficient navigation and maintenance of large projects.
Sequential Structure: It is a type of control structure where statements are executed in the
order in which they appear in the code, procedural. The flow of execution runs from the
top of the code to the bottom, executing every statement in sequential sequence.
Example:
```vb
Dim x As Integer
Dim y As Integer
x=5
y = 10
Dim z As Integer
z=x+y
```
Selection Structure : Selection structures allow the program to make decisions based on
certain conditions. In VB, this is often implemented using the If...Then...Else statement. This
structure evaluates a condition and executes different blocks of code based on whether the
condition is true or false.
Example:
```vb
age = 25
Else
End If
```
```vb
For i = 1 To 5
Next i
```
3.Design the GUI, specify the properties and write a VB program that accepts marks for 3 units
through textboxes, computes the total, average and then grades a student based on the criteria
given below using the If…ElseIf construct. The program should then use labels to display the
total mark, average and the grade. (7 marks)
AVERAGE GRADE
80-100 Distinction
70-79 Credit
60-69 Credit II
50-59 Pass
0-49 Fail
Any other Invalid Data Entry
- Place three TextBox controls named `txtUnit1`, `txtUnit2`, `txtUnit3` for entering
marks.
- Place three Label controls named `lblTotal`, `lblAverage`, `lblGrade` for displaying
the total mark, average mark, and grade.
- Place a Button control named `btnCalculate` for triggering the calculation and
grading process.
- For the TextBox controls, set the `Text` property to empty ("") initially.
- For the Label controls, set the `Text` property to empty ("") initially.
- Set the `Text` property of `btnCalculate` to "Calculate".
```vb
' Declare variables to hold marks and calculate total and average
Double.TryParse(txtUnit1.Text, mark1)
Double.TryParse(txtUnit2.Text, mark2)
Double.TryParse(txtUnit3.Text, mark3)
average = total / 3
Else
End If
End Sub
```
4. Design the GUI, specify the properties and write a VB program that accepts a number
through a textbox and then uses the Select Case construct to determine the 12
months of the year based on the number entered by the user. If a user enters 1, the
program displays January. If a user enters 6, the program displays June. Use a label for
display (4 marks)
- Place a TextBox control named `txtMonthNumber` for entering the month number.
- Place a Button control named `btnDisplayMonth` for triggering the display of
the month.
- Place a Label control named `lblMonthDisplay` to display the result.
' Use Select Case to determine the month based on the number entered
Select Case monthNumber
Case 1
lblMonthDisplay.Text = "January"
Case 2
lblMonthDisplay.Text = "February"
Case 3
lblMonthDisplay.Text = "March"
Case 4
lblMonthDisplay.Text = "April"
Case 5
lblMonthDisplay.Text = "May"
Case 6
lblMonthDisplay.Text = "June”
Case 7
lblMonthDisplay.Text = "July"
Case 8
lblMonthDisplay.Text = "August"
Case 9
lblMonthDisplay.Text = "September"
Case 10
lblMonthDisplay.Text = "October"
Case 11
lblMonthDisplay.Text = "November"
Case 12
lblMonthDisplay.Text = "December"
Case Else
lblMonthDisplay.Text = "Invalid Month Number"
End Select
End Sub
```
5.Write a VB progrm tuhat generates and displays a series of 6 numbers and their
sum through message boxes. The series order is 5,11,17. The program must use a loop. (7
marks)
vb
Module Module1
Sub Main()
Dim numbers() As Integer = {5, 11, 17}
Dim sum As Integer = 0
For i = 1 To 3
sum += numbers(i - 1)
MsgBox("Number " & i & ": " & numbers(i - 1))
Next
End Module