`
FACULTY OF BUSINESS AND INFORMATION
SCIENCE
ASSIGNMENT COVER PAGE
Student Id : 1 8 1 3 1 2
Student Name : Shital Bashyal
Email : [email protected]
Course Code : CC215
Course Name : VB.net
Semester : 5th semester
Session :
Instructor/Examiner/Lecturer : Purnima Mulmi
Assignment No. : Lab 8 Assignment
Assignment Type :
Submission Date : 6th March 2020
Marks Obtained : …………… out of..................
Evaluator’s Signature : ……………………
1 Design TWO (2) forms using vb net as the following: -
- The first form named “Main” with size 500,300 includes menus named File and
About
(i) The file menu has two menu items, Students and Exit
- Students menu item has two submenus Personal info and Academic info
- Personal Info calls the second form with size 300,200 and named “Personal Info”, this
form has controls as illustrated in the following figure.
Ans - Public Class main
Private Sub PersonalInfoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles PersonalInfoToolStripMenuItem.Click
Form2.Show()
End Sub
End Class
(ii) About menu has item named ” about this tutorial”, it shows some information such as “After
this tutorial students will be able to design menus and submenus”
Hint (Use formname.show() To call a form)
Ans- Private Sub AboutTheToolStripMenuItem_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles AboutTheToolStripMenuItem.Click
Form3.show()
End Sub
End Class
2 Design the following form. Use the Contexmenutstrip tool with illustrated items to copy
numbers from list1 and paste to list2
Ans
Coding
Public Class Form1
Dim data As String
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ListBox1.SelectedIndexChanged
End Sub
Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CopyToolStripMenuItem.Click
data = ListBox1.SelectedItem
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ExitToolStripMenuItem.Click
Application.Exit()
End Sub
Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles PasteToolStripMenuItem.Click
ListBox2.Items.Add(data)
End Sub
Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CutToolStripMenuItem.Click
data = ListBox1.SelectedItem
ListBox1.Items.Remove(data)
End Sub
End Class
3- Provide an example of calling MESSAGE BOX with
-Two Arguments
-Four Arguments
Ans MessageBox.Show("paste
Successfully" ,"Information",MessageBoxButtons.OK,MessageBoxIcon.Information)
4- Differentiate between sub procedure and function.
Ans Sub procedure
A procedure is a block of Visual Basic statements inside Sub, End Sub statements. Procedures do
not return values. Each procedure has a name. Inside the Main() procedure, we call our user
defined SimpleProcedure() procedure. Procedures are defined outside the Main() procedure.
Procedure name follows the Sub statement. When we call a procedure inside the Visual Basic
program, the control is given to that procedure. Statements inside the block of the procedure are
executed.
Function
A function is a block of Visual Basic statements inside Function, End Function statements.
Functions return values. There are two basic types of functions. Built-in functions and user
defined ones. The built-in functions are part of the Visual Basic language. There are various
mathematical, string or conversion functions.
5- List the advantages of using procedures in vb .net.
Ans
i. Reducing duplication of code.
ii. Decomposing complex problems into simpler pieces.
iii. Improving clarity of the code.
iv. Reuse of code.
v. Information hiding.
6- Differentiate between Parameters and arguments in VB .NET procedures.
Ans
Parameter - A parameter is something you have to fill in when you call a function. What you put
in it is the argument. This means a placeholder belongs to the function naming and be used in the
function body.
Argument - the argument goes into the parameter, an argument is the value of the parameter.This
means an actual value which is passed by the function calling.
7 State the result of the following function.
Public Function Functionname (intFirst As Integer, intSecond As Integer) As Integer
Return intFirst * intSecond
End Function
Ans value of “ intFirst * intSecond ”
8- You are required to write a procedure to calculate and return the average of three
integer values.
-Should you write a sub procedure or a function procedure?
Ans Function Procedure
-Write the header line of the procedure.
Ans Public Function Functionname (intFirst As Integer, intSecond As Integer) As Integer
-Write the calculation
Ans Return intFirst + intSecond + intThird
-How is the calculated average passed back to the calling procedure?
Ans By Writeline.Readline