Você está na página 1de 10

Question No 1:

Write a common function named sort it will compare the name and age of the employee and then show
the two lists of sorted employees with respect to their name and age.
Hint: Use delegates
Solution:

Public Delegate Function sort(ByVal name As String, ByVal age As String) As String

Public l As List(Of String) = New List(Of String)
l.Add("Ali","17")
l.Add("Umer","19")
l.Add("Shahzaib","24")
l.Add("Bilal","23")

l.Sort ()

For Each element As String In l
messagebox.show(element)
Next

Question No 2:
Make a form like this. Place 2 buttons on it.








Make two forms Login and change password. Their working is same like in windows.

Passward
Login button
Change Passward
button
Solution:













Public Class LogInForm
Public pass As String = "admin"
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLogin.Click

If pass = txtPass.Text Then
MsgBox("Your are successfully login", MsgBoxStyle.Information)
txtPass.Clear()

Else
MsgBox("User name or password incorrect please try again")

txtPass.Clear()
txtPass.Focus()

End If

End Sub



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
ChangePass.Show()
Me.Hide()

End Sub

Public Class ChangePass

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
LogInForm.pass = txtCpass.Text
MsgBox("Your new password is successfully updated ", MsgBoxStyle.Information)
txtCpass.Clear()


End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
LogInForm.Show()
Me.Hide()

End Sub
End Class

Question No 3:
Make below form. Make a class which has 2 properties of name and roll no
When user select post graduate/ undergraduate then combo box of select course is populate with
desired courses. When user select course then its relevant subject is added in a list box.
Behind calculate fees button:
When user click on calculate fee button then count total number of courses that user select in a list box
and multiply it with 2000. Fee of one subject is 2000. At the end show another form in which user detail
and calculated fee is shown.
Use class and arrays.
These features must be present in your form. If you will add extra features in it then you get extra
marks. Its interface must be user friendly. If you have any problem then send me a mail. Best of luck
























Frame1
Name of the student
Roll No

Frame2
Place 2 radio buttons here
Select your gender
Male
Female
Frame
Select course




Place combobox
here
BBA, BSCS,
B.com. etc for
undergraduate and
M.com. Msc for Post
graduate
Frame4
Place 2 radio buttons here
Under graduate
Post Graduate

Place List box here in
which name of
subjects are displayed.
Lis box style must be in
check box form.
Calculate Fee
button
Solution:

Public Class MainForm


Private Sub radUG_CheckedChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles radUG.CheckedChanged

If radUG.Checked = True Then
cmbCourse.Items.Clear() ' for clear combo box before display another custom
data values


cmbCourse.Items.Add("BBA")
cmbCourse.Items.Add("BSCS")
cmbCourse.Items.Add("B.Com")

End If



End Sub

Private Sub radPG_CheckedChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles radPG.CheckedChanged
If radPG.Checked = True Then
cmbCourse.Items.Clear() ' for clear combo box before display another custom
data values


cmbCourse.Items.Add("M.Com")
cmbCourse.Items.Add("MSc")

End If
End Sub

Private Sub cmbCourse_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmbCourse.SelectedIndexChanged
If cmbCourse.Text = "BBA" Then
ChListBoxCourse.Items.Clear()

ChListBoxCourse.Items.Add("Introduction to Business")
ChListBoxCourse.Items.Add("Money Banking and Finance")
ChListBoxCourse.Items.Add("Principles of Economics")
ChListBoxCourse.Items.Add("Principles of Accounting")
ChListBoxCourse.Items.Add("Business math & Stat")
ChListBoxCourse.Items.Add("Principles of Auditing")
ChListBoxCourse.Items.Add("Business Law")
End If
If cmbCourse.Text = "BSCS" Then
ChListBoxCourse.Items.Clear()
ChListBoxCourse.Items.Add("Introduction to Computer")
ChListBoxCourse.Items.Add("Introduction to Programming")
ChListBoxCourse.Items.Add("Visual Basic.Net")
ChListBoxCourse.Items.Add("C++")
ChListBoxCourse.Items.Add("Calcus Math")
ChListBoxCourse.Items.Add("E-Commerce")
ChListBoxCourse.Items.Add("Web development")
End If
If cmbCourse.Text = "B.Com" Then
ChListBoxCourse.Items.Clear()
ChListBoxCourse.Items.Add("Introduction to Business")
ChListBoxCourse.Items.Add("Money Banking and Finance")
ChListBoxCourse.Items.Add("Principles of Economics")
ChListBoxCourse.Items.Add("Principles of Accounting")
ChListBoxCourse.Items.Add("Business math & Stat")
ChListBoxCourse.Items.Add("Business Law")
ChListBoxCourse.Items.Add("Income Tax Law")
End If
If cmbCourse.Text = "MSc" Then
ChListBoxCourse.Items.Clear()
ChListBoxCourse.Items.Add("English")
ChListBoxCourse.Items.Add("Math")
ChListBoxCourse.Items.Add("Physics")
ChListBoxCourse.Items.Add("Computer")
ChListBoxCourse.Items.Add("System Analysis and Design")
ChListBoxCourse.Items.Add("Communication")
ChListBoxCourse.Items.Add("Ecnomics")
End If
If cmbCourse.Text = "M.Com" Then
ChListBoxCourse.Items.Clear()
ChListBoxCourse.Items.Add("Introduction to Business")
ChListBoxCourse.Items.Add("Money Banking and Finance")
ChListBoxCourse.Items.Add("Advance Accounting")
ChListBoxCourse.Items.Add("Cost Accounting")
ChListBoxCourse.Items.Add("Business math & Stat")
ChListBoxCourse.Items.Add("Principles of Auditing")
ChListBoxCourse.Items.Add("Business Law")
End If

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Dim a(10) As Integer
Dim s As Integer
If ChListBoxCourse.GetItemCheckState(0) Then
a(0) = 2000
s += a(0)
'MsgBox(a)
End If
If ChListBoxCourse.GetItemCheckState(1) Then
a(1) = 2000
s += a(1)
'MsgBox(a)
End If
If ChListBoxCourse.GetItemCheckState(2) Then
a(2) = 2000
s += a(2)
'MsgBox(a)
End If
If ChListBoxCourse.GetItemCheckState(3) Then
a(3) = 2000
s += a(3)
'MsgBox(a)
End If
If ChListBoxCourse.GetItemCheckState(4) Then
a(4) = 2000
s += a(4)
'MsgBox(a)
End If
If ChListBoxCourse.GetItemCheckState(5) Then
a(5) = 2000
s += a(5)
'MsgBox(a)
End If
If ChListBoxCourse.GetItemCheckState(6) Then
a(6) = 2000
s += a(6)
'MsgBox(a)
End If
' If ChListBoxCourse.GetItemCheckState(7) Then
'a(7) = 2000
's += a(7)
'MsgBox(a)
'End If
'If ChListBoxCourse.GetItemCheckState(8) Then
' a(8) = 2000
' s += a(8)
'MsgBox(a)
' End If
txtTotalFee.Text = s

End Sub

Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click

Dim indexChecked As Integer
Dim headline(7) As String


For Each indexChecked In ChListBoxCourse.CheckedIndices
' The indexChecked variable contains the index of the item.
headline(0) = Convert.ToString(ChListBoxCourse.Items(indexChecked)) & ","

StudentInfo.lstBoxCourse.Items.Add(headline(0))

Next


If radUG.Checked = True Then
Program = "Under Graduate"
End If
If radPG.Checked = True Then
Program = "Post Graduate"
End If
stdname = txtName.Text
rollNo = Val(txtRoll.Text)

If radM.Checked = True Then
gender = "Male"
End If
If radFm.Checked = True Then
gender = "Female"
End If

If radUG.Checked = True Then
Program = "Under Graduate"
End If
If radUG.Checked = True Then
Program = "Post Graduate"
End If
totalfee = Val(txtTotalFee.Text)
If txtName.Text = "" Or txtRoll.Text = "" Then
MsgBox("Please fill the empty fileds!")
Else
StudentInfo.Show()
Me.Hide()
End If
End Sub

Private Sub GroupBox2_Enter(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles GroupBox2.Enter

End Sub

Private Sub Label6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Label6.Click

End Sub
End Class

Part module:
Module Module1

Public stdname As String
Public rollNo As Integer
Public totalfee As Integer
Public gender, Program, course As String

' Public Delegate Function sort(ByVal name As String, ByVal age As String) As
String

'Public l As List(Of String) = New List(Of String)
'l.Add("Ali","17")
'l.Add("Umer","19")
'l.Add("Shahzaib","24")
'l.Add("Bilal","23")

' l.Sort ()

' For Each element As String In l
' messagebox.show(element)
' Next



Public Class students
Private m_Name As String
Private m_RollNo As Integer
Public Property Name() As String
Get
Return m_Name
End Get
Set(ByVal name As String)

End Set
End Property
Public Property RollNo() As Integer
Get
Return m_RollNo
End Get
Set(ByVal RollNo As Integer)

End Set
End Property
End Class
Public Function fee() As Integer
Dim sum As Integer = 0
Dim CSfee(32) As Integer
If MainForm.ChListBoxCourse.SelectedIndex = 0 Then

CSfee(0) = 2000
sum += CSfee(0)

End If
' If Form1.CheckedListBox1.SelectedIndices(1) Then

' CSfee(1) = 2000
' sum += CSfee(1)
' End If


End Function

End Module

Part 3 2
nd
form

Part 4 2
nd
form codes
Public Class StudentInfo

Private Sub StudentInfo_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
txtRoll.Text = rollNo
txtName.Text = Name
txtGender.Text = gender
txtProgram.Text = Program
txtTotFee.Text = CStr(totalfee)

End Sub
End Class

Você também pode gostar