Download as pdf or txt
Download as pdf or txt
You are on page 1of 76

VB.

net
LAB MANUAL
WINDOWS PRACTICALS
1) Write a program in VB.NET which will display the functionality of Button click
event using the MsgBox.

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
MessageBox.Show("Your Name is :- " & TextBox1.Text)
End Sub
End Class

OUTPUT:-

1
2) Write a program in VB.NET which will change double to integer data type and
showing the result on lable on the command button click event.

Public Class Frmprog2

2
Private Sub Frmprog2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click

Dim a As Double

a = TextBox1.Text
Label3.Text = CInt(TextBox1.Text)
End Sub
End Class
OUTPUT:-

3) Write a program in VB.NET which will display the functionality of isDate() function.

3
Public Class Frmprog3

Private Sub Frmprog3_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
If (IsDate(TextBox1.Text)) Then
MsgBox("Accepted")
Else
MsgBox("Try Again")
End If
End Sub
End Class
OUTPUT:-

4) Write a program in VB.NET which will check if a assignment is numeric or not using
isNumeric() function.

4
Public Class Frmprog4

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub

Private Sub clickme_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles clickme.Click
If TextBox1.Text.Length < 10 And IsNumeric(TextBox1.Text) Then
MsgBox("Accepted")
Else
MsgBox("Try Again")
End If
End Sub
End Class
OUTPUT:-

5
5) Write a program in VB.NET showing the functionality to enter any two numbers in
two different textboxes and create buttons of +,-,X,\,^,/ and MOD. Display the
answer on label

Public Class Frmprog5

Private Sub Frmprog5_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim a, b, c As Integer
a = TextBox1.Text
b = TextBox2.Text

c=a+b
Label4.Text = c
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
Label4.Text = TextBox1.Text - TextBox2.Text

6
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button3.Click
Label4.Text = TextBox1.Text * TextBox2.Text
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button4.Click
Label4.Text = TextBox1.Text / TextBox2.Text
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button5.Click
Label4.Text = TextBox1.Text \ TextBox2.Text
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button6.Click
Label4.Text = TextBox1.Text Mod TextBox2.Text
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button7.Click
Label4.Text = TextBox1.Text ^ TextBox2.Text
End Sub

End Class
OUTPUT:-

7
6) Enter any number in inputbox and check it is zero , positive or negative using if.. end
if

Public Class Frmprog6

Private Sub Frmprog6_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
Dim a As Integer
a = InputBox("Enter The Numebr:- ")
If a = 0 Then
MessageBox.Show("The Number is Zero")
ElseIf a > 0 Then
MessageBox.Show("The Number is Positive")
ElseIf a < 0 Then
MessageBox.Show("The Number is Nagative ")
End If
End Sub
End Class

OUTPUT:-

8
7) Write an application in vb.net in which enter one number in textbox and find out is it 1.
Even/odd 2. Prime/not 3. Magic/not 4. Factorial 5. Square root of it when we put mouse
on respective labels

9
Imports System.Math
Public Class Frmprog7

Private Sub Frmprog7_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub

Private Sub Label1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs)


Handles Label1.MouseEnter
If txtitem.Text Mod 2 = 0 Then
Lbeo.Text = "EVEN"
Else
Lbeo.Text = "ODD"

End If
End Sub

Private Sub Label2_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs)


Handles Label2.MouseEnter
Dim i As Integer = 2
Dim prime As Integer
For i = 2 To txtitem.Text - 1 Step 1
If (txtitem.Text Mod i = 0) Then
prime = 1

10
End If
Next

If (prime = 0) Then
lbprime.Text = "Prime"
Else
lbprime.Text = "Not Prime"
End If
End Sub

Private Sub Label3_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs)


Handles Label3.MouseEnter
lbmagic.Text = txtitem.Text Mod 9 = 0
End Sub

Private Sub Label4_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs)


Handles Label4.MouseEnter
Dim i, j As Double
j=1
For i = 1 To CInt(txtitem.Text)
j =j*i
Next
lbfact.Text = j

End Sub

Private Sub Label6_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs)


Handles Label6.MouseEnter
lbsqrt.Text = Sqrt(CInt(txtitem.Text))
End Sub

End Class
OUTPUT:-

11
8) Enter year in a textbox and check year is leap / not on label control

Public Class Frmprog8

Private Sub Frmprog8_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
If CInt(TextBox1.Text) Mod 4 = 0 Then
Label2.Text = TextBox1.Text & " is Leap year"
Else
Label2.Text = TextBox1.Text & " is not leap year"
End If

12
End Sub

End Class
OUTPUT:-

9) Write a program in VB.NET which will ask the values from users and will display the
result by using the functionality of Select-Case

13
Public Class Frmprog9

Private Sub Frmprog9_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim a As Integer
a = CInt(TextBox3.Text)
Select Case a
Case 1
Label11.Text = CInt(TextBox1.Text) + CInt(TextBox2.Text)
Case 2
Label11.Text = CInt(TextBox1.Text) - CInt(TextBox2.Text)
Case 3
Label11.Text = CInt(TextBox1.Text) * CInt(TextBox2.Text)
Case 4
Label11.Text = CInt(TextBox1.Text) / CInt(TextBox2.Text)
Case Else
Label11.Text = "You have entered a wrong choice "

End Select
End Sub
End Class
OUTPUT:-

14
10) Write a program in VB.NET which will display the functionality of trim function
which will remove the charatcters as per requirement

Public Class frmprog10

Private Sub frmprog10_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
MsgBox(TextBox1.Text.Length)
'MsgBox(Label1.Text.Length)
End Sub
End Class
OUTPUT:-

15
S

11)Write a program in VB.NET which will display the functionality of UCase, LCase,
ToUpper, ToLower

Public Class frmprog11

Private Sub frmprog11_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load

16
Me.WindowState = FormWindowState.Maximized
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
TextBox1.Text = LCase(TextBox1.Text)
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
TextBox1.Text = UCase(TextBox1.Text)
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button3.Click
TextBox1.Text = TextBox1.Text.ToUpper

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button4.Click
TextBox1.Text = TextBox1.Text.ToLower
End Sub
End Class

17
12) Write a program in VB.NET which will display the functionality of listbox

Public Class Frmprog12


Private Sub Btn_Selection_Mode_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Btn_Selection_Mode.Click
ListBox1.SelectionMode = SelectionMode.MultiSimple
End Sub

Private Sub Btn_Selection_Item_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Btn_Selection_Item.Click
MsgBox(ListBox1.SelectedItem, MsgBoxStyle.Information)
End Sub

Private Sub Btn_Selected_Item_Index_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Btn_Selected_Item_Index.Click
MsgBox(ListBox1.SelectedIndex)
End Sub

Private Sub BTNSITEMS_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles BTNSITEMS.Click
Dim i As Integer
For i = 0 To ListBox1.SelectedItems.Count - 1

18
MsgBox(ListBox1.SelectedItems.Item(i))
Next
End Sub

Private Sub BTNINDICES_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles BTNINDICES.Click
Dim i As Integer
For i = 0 To ListBox1.SelectedIndices.Count - 1
MsgBox(ListBox1.SelectedIndices.Item(i))
Next
End Sub

Private Sub BTNCOUNT_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles BTNCOUNT.Click
If ListBox1.SelectedItems.Count = 0 Then
MsgBox(ListBox1.Items.Count)
Else
MsgBox(ListBox1.SelectedItems.Count)
End If
End Sub

Private Sub BTNADD_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles BTNADD.Click
Dim s As String
s = InputBox("Enter Any Food Name : ")
ListBox1.Items.Add(s)
End Sub

Private Sub BTNREMOVE_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles BTNREMOVE.Click
ListBox1.Items.Remove(ListBox1.SelectedItem)
End Sub

Private Sub BTNREMOVEAT_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles BTNREMOVEAT.Click
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
End Sub

Private Sub BTNREMMULTI_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles BTNREMMULTI.Click
Dim I As Integer
For I = 0 To ListBox1.SelectedItems.Count - 1
ListBox1.Items.Remove(ListBox1.SelectedItems.Item(0))
Next
End Sub

19
Private Sub BTNINSERT_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles BTNINSERT.Click
Dim s As String
Dim i As Integer
i -= 1
i = InputBox("Enter Location Where u want to Insert")
s = InputBox("Enter FoodName:")
ListBox1.Items.Insert(i, s)
End Sub

Private Sub BTNCLEAR_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles BTNCLEAR.Click
ListBox1.Items.Clear()
End Sub

Private Sub BTNCONTAIN_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles BTNCONTAIN.Click
Dim s As String

s = InputBox("Enter Food Item")


If ListBox1.Items.Contains(s) = True Then
MsgBox("Alredy Exist")
Else
MsgBox("Not Exist")
End If
End Sub

Private Sub BTNFINDSTRING_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles BTNFINDSTRING.Click
Dim s As String

s = InputBox("Enter Food Item")


If ListBox1.FindString(s) < 0 Then
MsgBox("Not Exist")
Else
MsgBox("Alredy Exist")
End If

End Sub

Private Sub BTNADDRANGE_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles BTNADDRANGE.Click
ListBox2.Items.AddRange(ListBox1.Items)
End Sub
End Class

20
13)Write a program in VB.NET which will display the functionality of Combobox

Public Class Frmprog13

Private Sub Frmprog13_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
ComboBox1.Items.Add(TextBox1.Text)
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
MsgBox(ComboBox1.SelectedIndex)
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button3.Click

21
MsgBox(ComboBox1.SelectedItem)
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button5.Click
ComboBox1.Items.Remove(ComboBox1.SelectedItem)
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button4.Click
ComboBox1.Items.Clear()
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button6.Click
ComboBox1.Items.RemoveAt(ComboBox1.SelectedIndex)
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button7.Click
Dim b As String = InputBox("enter item:- ")
Dim a As Integer = InputBox("Enter Position:- ")

a -= 1
If ComboBox1.Items.Contains(b) = False Then

ComboBox1.Items.Insert(a, b)
Else
MsgBox("Alredy In list")

End If

End Sub
End Class
OUTPUT:-

22
23
14)Enter student’s name, pick up degree and year from combo box and then enter 7
subject marks in textboxes, then calculate total, per and print grade on various label
using lost focus event of textbox

24
Public Class Frmprog14

Private Sub TXTS7_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs)


Handles TXTS7.LostFocus
Frmprog14_1.Show()

Frmprog14_1.LABNAME.Text = TXTNAME.Text
Frmprog14_1.LABDEGREE.Text = COMBOCOURCE.SelectedItem
Frmprog14_1.LABYEAR.Text = COMBOYEAR.SelectedItem
Frmprog14_1.LABS1.Text = TXTS1.Text
Frmprog14_1.LABS2.Text = TXTS2.Text
Frmprog14_1.LABS3.Text = TXTS3.Text
Frmprog14_1.LABS4.Text = TXTS4.Text
Frmprog14_1.LABS5.Text = TXTS5.Text
Frmprog14_1.LABS6.Text = TXTS6.Text
Frmprog14_1.LABS7.Text = TXTS7.Text

25
Frmprog14_1.LABTOT.Text = CInt(TXTS1.Text) + CInt(TXTS2.Text) +
CInt(TXTS3.Text) + CInt(TXTS4.Text) + CInt(TXTS5.Text) + CInt(TXTS6.Text) +
CInt(TXTS7.Text)
Frmprog14_1.LABPR.Text = (Frmprog14_1.LABTOT.Text / 7)

If Frmprog14_1.LABPR.Text >= 90 And Frmprog14_1.LABPR.Text < 100 Then


Frmprog14_1.LABGRADE.Text = "A+"
ElseIf Frmprog14_1.LABPR.Text >= 75 And Frmprog14_1.LABPR.Text < 90
Then
Frmprog14_1.LABGRADE.Text = "A"
ElseIf Frmprog14_1.LABPR.Text >= 60 And Frmprog14_1.LABPR.Text < 75
Then
Frmprog14_1.LABGRADE.Text = "B"
ElseIf Frmprog14_1.LABPR.Text >= 40 And Frmprog14_1.LABPR.Text < 60
Then
Frmprog14_1.LABGRADE.Text = "C"
End If
End Sub

Private Sub Frmprog14_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub
End Class
OUTPUT:-

26
15)Enter employee name , pick up dept name from combo box , and then enter basic
salary into textbox and using keypress event calculate total salary using [ HRA (35%) , DA
(85%) , MA ( 10%) , TA (15%).. ,-> Total Salary , Deduction : PF (8.5%) , IT (15%), Loan-fund
(10%)-> deduction , finally find out Net salary using key press event)

27
Public Class Frmprog15

Private Sub Frmprog15_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub

Private Sub txtbasic_LostFocus(ByVal sender As Object, ByVal e As


System.EventArgs) Handles txtbasic.LostFocus
Dim A As Integer = txtbasic.Text
LBHRA.Text = (A * 35 / 100)

LBDA.Text = (A * 85 / 100)

LBMA.Text = (A * 10 / 100)

LBTA.Text = (A * 15 / 100)

LBPF.Text = (A * 8.5 / 100)

LBIT.Text = (A * 15 / 100)

28
LBLF.Text = (A * 10 / 100)

LBSALAY.Text = ((CInt(LBHRA.Text) + CInt(LBDA.Text) + CInt(LBMA.Text) +


CInt(LBTA.Text)) - (CInt(LBPF.Text) + CInt(LBIT.Text) + CInt(LBLF.Text)))
LBPROFIT.Text = (CInt(LBSALAY.Text) - txtbasic.Text)
End Sub
End Class
OUTPUT:-

16)Write an application in vb.net which put one button named ‘Input Data’ When we click
on it, it ask as minimum and maximum value. Then one combobox should display even ,
odd , prime are the list item when we click on any of them, between min to max that list
item’s numbers should be display at label

17)Write a program in VB.NET which show functionality of radiobutton and checkbox.

29
Public Class Frmprog17

Private Sub btnsubmit_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnsubmit.Click

Dim s As String
Dim p As String
'Frmprog2.Label1.Text = "your Name is:- " & txtname.Text
'Frmprog2.Label2.Text = "your address is:- " & txtadd.Text
'Frmprog2.Label3.Text = "your phone number is:- " & txtph.Text

If radmale.Checked = True Then

s = "Male"

ElseIf radfemale.Checked = True Then

30
s = "Female"
End If
If radcash.Checked = True Then
p = " Cash"
ElseIf radcr.Checked = True Then
p = "Credit"

End If
'If radcash.Checked = True Then
'Frmprog2.Label5.Text = "Your Payment Mode Is Cash"
'ElseIf radcr.Checked = True Then
'Frmprog2.Label5.Text = "Your Payment Mode is credit"

'End If
Dim c As String
If CHKS.Checked = True And CHKT.Checked = True And CHKR.Checked = True
Then
c = "Singing, Travelling And Reading"
ElseIf CHKS.Checked = True And CHKT.Checked = True Then
c = "Singing And Travelling "
ElseIf CHKS.Checked = True And CHKR.Checked = True Then
c = "Singing And Reading"
ElseIf CHKT.Checked = True And CHKR.Checked = True Then
c = "Travelling And Reading"
ElseIf CHKS.Checked = True Then
c = "Singing"
ElseIf CHKT.Checked = True Then
c = "Travelling"
ElseIf CHKR.Checked = True Then
c = "Reading"

End If
MsgBox("Your Name is : " & txtname.Text & vbNewLine & "Your Address is : " &
txtadd.Text & vbNewLine & "Your phone number is: " & txtph.Text & vbNewLine &
"Your Gender is: " & s & vbNewLine & "Your Payment Mode is :" & p & vbNewLine &
"Your Hobbies Is : " & c)

End Sub

Private Sub Frmprog17_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub
End Class
OUTPUT:-

31
18)Write an application in vb.net which has check boxes and parallel textboxes are there
on selection of checkbox - Item name , price and quantity textbox display ( visible ) . enter
qty and for multiple item generate the total bill and get net bill at label using following
discount scheme
Total bill Discount
1000 – 2000 Rs. 10%
2000 – 5000 Rs. 20%
>=5000 Rs. 25%

32
Public Class Frmprog18

Private Sub Frmprog18_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
TextBox1.Text = "Sunsilk Shampoo 250 ml"
TextBox2.Text = "Pears Soap"
TextBox3.Text = "Fogg Deo Men's"
Me.WindowState = FormWindowState.Maximized
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
If CheckBox1.Checked = True And CheckBox2.Checked = True And CheckBox3.Checked =
True Then
TextBox4.Text = "330"
ElseIf CheckBox1.Checked = True And CheckBox2.Checked = True Then
TextBox4.Text = "135"
ElseIf CheckBox1.Checked = True And CheckBox3.Checked = True Then
TextBox4.Text = "290"
ElseIf CheckBox2.Checked = True And CheckBox3.Checked = True Then
TextBox4.Text = "235"
ElseIf CheckBox1.Checked = True Then
TextBox4.Text = "95"
ElseIf CheckBox2.Checked = True Then
TextBox4.Text = "40"
ElseIf CheckBox3.Checked = True Then

33
TextBox4.Text = "195"
End If
End Sub

Private Sub TextBox5_KeyUp(ByVal sender As Object, ByVal e As


System.Windows.Forms.KeyEventArgs) Handles TextBox5.KeyUp
Label5.Text = TextBox4.Text * TextBox5.Text

If Label5.Text > 1000 And Label5.Text < 2000 Then


Label6.Text = (Label5.Text - Label5.Text * 10 / 100)
ElseIf Label5.Text > 2000 And Label5.Text < 5000 Then
Label6.Text = (Label5.Text - Label5.Text * 20 / 100)
ElseIf Label5.Text >= 5000 Then
Label6.Text = (Label5.Text - Label5.Text * 25 / 100)
End If
End Sub

End Class

OUTPUT:-

19)Write an application in vb.net which display one textbox and having three radio
buttons named ‘left justify’ , ‘ right justify ‘ and ‘center ‘ when we click on it,it should
works

34
Public Class Frmprog19

Private Sub Frmprog19_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub

Private Sub RADLEFT_CheckedChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles RADLEFT.CheckedChanged
If RADLEFT.Checked = True Then
TXT.TextAlign = HorizontalAlignment.Left
End If
End Sub

Private Sub RADCENTER_CheckedChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles RADCENTER.CheckedChanged
If RADCENTER.Checked = True Then
TXT.TextAlign = HorizontalAlignment.Center
End If
End Sub

Private Sub RADRIGHT_CheckedChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles RADRIGHT.CheckedChanged
If RADRIGHT.Checked = True Then
TXT.TextAlign = HorizontalAlignment.Right
End If
End Sub
End Class
OUTPUT:-

35
20)Write an application in vb.net which has 1 combo box for menu type ( Guj. Punjabi ,
Chinese) then after at the selection of menu type, menu items are added to the listbox at
dynamic level. Finally selection of menu item, price should be display at label and quantity
textbox appear, at key press event of textbox get the bill of order.

Public Class Frmprog20

36
Private Sub Frmprog20_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.SelectedItem = "Gujarati" Then
ListBox1.Items.Clear()
ListBox1.Items.Add("Shak-puri")
ListBox1.Items.Add("Khichdi-dahi")
ListBox1.Items.Add("Full Dish")
ListBox1.Items.Add("Sweet Dish")

ElseIf ComboBox1.SelectedItem = "Panjabi" Then


ListBox1.Items.Clear()
ListBox1.Items.Add("Panir Masala")
ListBox1.Items.Add("Aalu Pharotha")
ListBox1.Items.Add("Veg Handi")
ListBox1.Items.Add("Kaju Panir")
ListBox1.Items.Add("Kaju Masala")
ElseIf ComboBox1.SelectedItem = "Chinese" Then
ListBox1.Items.Clear()
ListBox1.Items.Add("Dry Manchurian")
ListBox1.Items.Add("Grevy Manchurian")
ListBox1.Items.Add("Chinese Bhel")
ListBox1.Items.Add("Shoup")
ListBox1.Items.Add("Salad")
End If
End Sub
Private Sub BTNGET_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles BTNGET.Click
If ListBox1.SelectedItem = "Shak-puri" Then
lbprice.Text = " 40"
ElseIf ListBox1.SelectedItem = "Khichdi-dahi" Then
lbprice.Text = " 40"
ElseIf ListBox1.SelectedItem = "Full Dish" Then
lbprice.Text = " 50"
ElseIf ListBox1.SelectedItem = "Sweet Dish" Then
lbprice.Text = " 30"
ElseIf ListBox1.SelectedItem = "Panir Masala" Then
lbprice.Text = "55"
ElseIf ListBox1.SelectedItem = "Aalu Pharotha" Then
lbprice.Text = " 30"
ElseIf ListBox1.SelectedItem = "Veg Handi" Then
lbprice.Text = " 70"
ElseIf ListBox1.SelectedItem = "Kaju Panir" Then

37
lbprice.Text = " 80"
ElseIf ListBox1.SelectedItem = "Kaju Masala" Then
lbprice.Text = " 60"
ElseIf ListBox1.SelectedItem = "Dry Manchurian" Then
lbprice.Text = " 45"
ElseIf ListBox1.SelectedItem = "Grevy Manchurian" Then
lbprice.Text = " 50"
ElseIf ListBox1.SelectedItem = "Chinese Bhel" Then
lbprice.Text = " 50"
ElseIf ListBox1.SelectedItem = "Shoup" Then
lbprice.Text = " 30"
ElseIf ListBox1.SelectedItem = "Salad" Then
lbprice.Text = " 20"
End If
End Sub

Private Sub txtquantity_KeyUp(ByVal sender As Object, ByVal e As


System.Windows.Forms.KeyEventArgs) Handles txtquantity.KeyUp
lbbill.Text = lbprice.Text * txtquantity.Text
End Sub
End Class
OUTPUT:-

38
21)Write an application in vb.net which display 1 textbox , 2 check box named ‘red’ . ‘blue’
for background color and 2 check box named ‘yellow’ and ‘green’ for foreground color
when we click it , it should works

Public Class Frmprog21


Private Sub Frmprog21_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized

End Sub

Private Sub CHKYELLOW_CheckedChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles CHKYELLOW.CheckedChanged
If CHKYELLOW.Checked Then
TXTBOX.ForeColor = Color.Yellow
End If

End Sub

Private Sub CHKGREEN_CheckedChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles CHKGREEN.CheckedChanged
If CHKGREEN.Checked Then
TXTBOX.ForeColor = Color.Green
End If
End Sub

Private Sub CHKRED_CheckedChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles CHKRED.CheckedChanged
If CHKRED.Checked Then
TXTBOX.BackColor = Color.Red

39
End If
End Sub

Private Sub CHKBLUE_CheckedChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles CHKBLUE.CheckedChanged
If CHKBLUE.Checked Then
TXTBOX.BackColor = Color.Blue
End If
End Sub
End Class

OUTPUT:-

22)Write a program in VB.NET which will implement the mouse entered event and will
give the message when mouse is entered onto the form

40
Public Class Frmprog22

Private Sub Button1_MouseEnter(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.MouseEnter
Me.BackColor = Color.Aqua

MsgBox("colocr has changed due to mouse enter event")


End Sub

Private Sub Frmprog22_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub
End Class
OUTPUT:-

41
23)Write a program in VB.NET which will display the functionality of minimum 3 events of
Button and textbox control.

Public Class Frmprog23

Private Sub Button2_KeyDown(ByVal sender As System.Object, ByVal e As


System.Windows.Forms.KeyEventArgs) Handles Button2.KeyDown

42
MsgBox("THIS IS BUTTON KEYDOWN EVENT")
End Sub

Private Sub Button3_MouseMove(ByVal sender As System.Object, ByVal e As


System.Windows.Forms.MouseEventArgs) Handles Button3.MouseMove
MsgBox("THIS IS MOUSEMOVE EVENT OF BUTTON")
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
MsgBox("THIS IS BUTTON CLICK EVENT")
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
MsgBox("PRESS ANY KEY")
End Sub

Private Sub TextBox1_MouseDoubleClick(ByVal sender As System.Object, ByVal e As


System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDoubleClick
MsgBox("THIS IS TEXTBOX DOUBLE CLICK EVENT")
End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles TextBox1.TextChanged
MsgBox("CKECK OUT DOUBLE CLICKING THE TEXTBOX")
End Sub

Private Sub TextBox2_MultilineChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles TextBox2.MultilineChanged
MsgBox("HEY THS IS TEXTBOX MULTILINECHANGED EVENT." & vbNewLine &
"OCCURS WHEN TEXTCHANGED EVENT OCCURS")
End Sub

'Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles TextBox2.TextChanged
' TextBox2.Multiline = True
'End Sub

Private Sub TextBox3_KeyUp(ByVal sender As System.Object, ByVal e As


System.Windows.Forms.KeyEventArgs) Handles TextBox3.KeyUp
MsgBox("THIS IS TEXTBOX KEYUP EVENT")
End Sub

Private Sub frmpro23_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load

43
Me.WindowState = FormWindowState.Maximized
End Sub

Private Sub TextBox2_KeyDown(ByVal sender As System.Object, ByVal e As


System.Windows.Forms.KeyEventArgs) Handles TextBox2.KeyDown
MsgBox("keydown event")
End Sub
End Class

24)Write a program in VB.NET which will show the functionality of FOR-NEXT WHILE loop
with the STEP in MINUS

Public Class Frmprog24

Private Sub Frmprog24_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized

For i = 10 To 1 Step -1
Label1.Text &= i
Next
End Sub
End Class
OUTPUT:-

25)Write a program in VB.NET which will show the functionality of DO - LOOP WHILE

44
Public Class Frmprog25

Private Sub Frmprog25_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
Dim i As Integer = 1
Do While i <= 10
Label1.Text &= i
i=i+1
Loop
End Sub
End Class

26)Write a program in VB.NET showing the functionality of WHILE - END .

Public Class Frmprog26

Private Sub Frmprog26_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized

Dim i As Integer = 1
While i <= 10

45
label1.text &= i
i=i+1

End While
End Sub
End Class

OUTPUT:-

27)Write a program in VB.NET which will show functionality of For-Each statement

Public Class Frmprog27

Private Sub Frmprog27_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized

Dim a As String
Dim b As Char

a = "ARPAN"
For Each b In a
MsgBox(b)
Label1.Text = b
Next
End Sub

End Class

OUTPUT:-

46
28)Write a program in VB.NET to validate a text box to allow only enter numeric data in it
else give msgbox

Public Class Frmprog28

Private Sub Frmprog28_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As


System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

47
If Asc(e.KeyChar) > 47 And Asc(e.KeyChar) < 58 Then
MsgBox("correct")
Else
MsgBox("enter no. only")
e.KeyChar = ""
End If
'If TextBox1.Text >= 0 And TextBox1.Text <= 9 Then
' MsgBox("correct")
'Else
' MsgBox("wrong")
'End If
End Sub
End Class
OUTPUT:-

29)Write an Application in Vb.net which transfer each data value from listbox1 to listbox2
by cliking of ‘>’ , ‘>>’ , ‘<’ , ‘<<’ same with listbox2 to listbox1.

48
Public Class Frmprog29
Private Sub frmpro29_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized

End Sub

Private Sub one_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles one.Click
ListBox1.SelectionMode = SelectionMode.One
ListBox2.SelectionMode = SelectionMode.One
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button4.Click
ListBox2.Items.Add(ListBox1.SelectedItem)
ListBox1.Items.Remove(ListBox1.SelectedItem)
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button5.Click
Dim I As Integer
For I = 0 To ListBox1.SelectedItems.Count - 1
ListBox2.Items.Add(ListBox1.SelectedItems.Item(0))
ListBox1.Items.Remove(ListBox1.SelectedItems.Item(0))

49
Next

End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button8.Click
ListBox2.Items.AddRange(ListBox1.Items)
ListBox1.Items.Clear()
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button6.Click
ListBox1.Items.Add(ListBox2.SelectedItem)
ListBox2.Items.Remove(ListBox2.SelectedItem)
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button7.Click
Dim I As Integer
For I = 0 To ListBox2.SelectedItems.Count - 1
ListBox1.Items.Add(ListBox2.SelectedItems.Item(0))
ListBox2.Items.Remove(ListBox2.SelectedItems.Item(0))

Next
End Sub

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button9.Click
ListBox1.Items.AddRange(ListBox2.Items)
ListBox2.Items.Clear()
End Sub

Private Sub more_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles more.Click
ListBox1.SelectionMode = SelectionMode.MultiSimple
ListBox2.SelectionMode = SelectionMode.MultiSimple
End Sub
End Class

30)Write an Application in vb.net in which a scrollbar has value of 1 to 10 as per scrolling


of it find out the squre root and factorial number at proper labels.

50
Imports System.Drawing
'Imports System.Windows.Forms.PictureBox
Imports System.Math

Public Class frmprog30

Dim demoimage(3) As String


Private Sub frmprog30_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized

demoimage(0) = "D:\college
Files\vb.Net\Task\WinPracticallist\WinPracticallist\DEMOIMAGE\Pallavi
Pandya 014.png"
demoimage(1) = "D:\college
Files\vb.Net\Task\WinPracticallist\WinPracticallist\DEMOIMAGE\Pallavi
Pandya 018.png"

51
demoimage(2) = "D:\college
Files\vb.Net\Task\WinPracticallist\WinPracticallist\DEMOIMAGE\Pallavi
Pandya 019.png"
demoimage(3) = "D:\college
Files\vb.Net\Task\WinPracticallist\WinPracticallist\DEMOIMAGE\Pallavi
Pandya 027.png"
PictureBox1.Image = Image.FromFile(demoimage(0))

End Sub

Private Sub VScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As


System.Windows.Forms.ScrollEventArgs) Handles VScrollBar1.Scroll
PictureBox1.Image = Image.FromFile(demoimage(VScrollBar1.Value - 1))
Me.Text = VScrollBar1.Value
End Sub

Private Sub HScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As


System.Windows.Forms.ScrollEventArgs) Handles HScrollBar1.Scroll
Label6.Text = HScrollBar1.Value
Label2.Text = Math.Sqrt(HScrollBar1.Value)

Dim i, j As Double
j=1
For i = 1 To HScrollBar1.Value
j=j*i
Next
Label4.Text = j
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
HScrollBar1.Maximum = ComboBox1.SelectedItem
End Sub
End Class
OUTPUT:-

52
31)Write an application in vb.net which has three scroll bar named ‘red’ , ‘blue’ and
‘green’ having maximum value of 255 on scrolling of each 1 label color must be changed as
per their value

32)Write a program in VB.NET to create an application having functionality like cut, copy,
paste, clear etc in textbox using button.

53
Public Class frmprog32

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
TextBox1.Cut()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
TextBox1.Copy()
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button3.Click
TextBox1.Paste()
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button4.Click

54
TextBox1.Undo()
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button5.Click
If TextBox1.CanUndo = True Then
TextBox1.Undo()
TextBox1.ClearUndo()
End If

End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button6.Click
TextBox1.Clear()
End Sub

Private Sub frmprog32_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub
End Class

33)Write an application in vb.net which that display your five friends name with different
images using auto execution of timer having 1 seconds [ use timer , interval – property ,
_tick event]

55
Public Class Frmprog33
Public I As Integer = 1
Private Sub Frmprog33_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
Timer1.Start()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click

56
Timer1.Stop()
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Timer1.Tick
If I = 1 Then
PictureBox1.Image = Image.FromFile("D:\college
files\vb.net\Prac_assignment\Prac_assignment\3D Monster.jpg")
I += 1
Label1.Text = "Shashank"
ElseIf I = 2 Then
PictureBox1.Image = Image.FromFile("D:\college
files\vb.net\Prac_assignment\Prac_assignment\Bang.jpg")
I += 1
Label1.Text = "Amit"
ElseIf I = 3 Then
PictureBox1.Image = Image.FromFile("D:\college
files\vb.net\Prac_assignment\Prac_assignment\Be Happy.jpg")
I += 1
Label1.Text = "Tejswi"
ElseIf I = 4 Then
PictureBox1.Image = Image.FromFile("D:\college
files\vb.net\Prac_assignment\Prac_assignment\Chromedroid V
2.jpg")
I=1
Label1.Text = "Jaimi"
End If

End Sub
End Class

34)Rotating different picture ( images ) in a picture box using timer tool

57
Public Class Frmprog34
Public I As Integer = 1
Private Sub Frmprog34_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
Timer1.Start()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
Timer1.Stop()

58
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Timer1.Tick
If I = 1 Then
PictureBox1.Image = Image.FromFile("D:\college
files\vb.net\Prac_assignment\Prac_assignment\3D Monster.jpg")
I += 1

ElseIf I = 2 Then
PictureBox1.Image = Image.FromFile("D:\college
files\vb.net\Prac_assignment\Prac_assignment\Bang.jpg")
I += 1

ElseIf I = 3 Then
PictureBox1.Image = Image.FromFile("D:\college
files\vb.net\Prac_assignment\Prac_assignment\Be Happy.jpg")
I += 1

ElseIf I = 4 Then
PictureBox1.Image = Image.FromFile("D:\college
Files\vb.Net\Task\WinPracticallist\WinPracticallist\DEMOIMAGE\Cool
_Clock.jpg")
I += 1
ElseIf I = 5 Then
PictureBox1.Image = Image.FromFile("D:\college
Files\vb.Net\Task\WinPracticallist\WinPracticallist\DEMOIMAGE\Do
or Die.jpg")
I += 1
ElseIf I = 6 Then
PictureBox1.Image = Image.FromFile("D:\college
Files\vb.Net\Task\WinPracticallist\WinPracticallist\DEMOIMAGE\Don
t Scare Me.jpg")
I += 1
ElseIf I = 7 Then
PictureBox1.Image = Image.FromFile("D:\college
Files\vb.Net\Task\WinPracticallist\WinPracticallist\DEMOIMAGE\Abst
ract Tiger.jpg")
I=1
End If
End Sub
End Class

35)Write an application in vb.net which display real calculator having 0-9 , . , clear , +,-,*,/,
and = button

59
I
36)Write a program in VB.NET which will display the functionality of RichTextBox which
will change the background color and foreground color (font color)

Public Class frmprog36

Private Sub frmprog36_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub

Private Sub FORECOLORToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles FORECOLORToolStripMenuItem.Click
`ColorDialog1.ShowDialog()

60
If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
RichTextBox1.ForeColor = ColorDialog1.Color
End If

End Sub

Private Sub BACKCOLORToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles BACKCOLORToolStripMenuItem.Click
`ColorDialog1.ShowDialog()
If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
RichTextBox1.BackColor = ColorDialog1.Color
End If
End Sub
End Class

37)Write a program in VB.NET which will on click of button open OpenFileDialog and
display file name.

61
Public Class Frmprog37

Private Sub Frmprog37_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
OpenFileDialog1.Filter = "TEXT FILE|*.TXT|WORD FILE|*.DOC|ALL FILES|*.*"

If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then


RichTextBox1.LoadFile(OpenFileDialog1.FileName,
RichTextBoxStreamType.PlainText)

End If
End Sub

62
End Class

38)Write a program in VB.NET which will on click of buttton open the FontDialog and
apply effect on RichTextBox

Public Class Frmprog38

Private Sub Frmprog38_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub

63
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If FontDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
RichTextBox1.SelectionFont = FontDialog1.Font
RichTextBox1.SelectionColor = FontDialog1.Color
End If
End Sub
End Class

39)Write a program in VB.NET which will display images and display selected images in
picturebox using OpenFileDialog

Public Class Frmprog39

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click

64
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
End If
End Sub

Private Sub Frmprog39_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub
End Class

40)Write a program in VB.NET which will display the functionality of colordialogbox which
will change the background color of the form runtime.

Public Class Frmprog40

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Me.BackColor = ColorDialog1.Color
End If
End Sub

Private Sub Frmprog40_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized

65
End Sub
End Class

41)Write a program in VB.NET which will display the functionality of TreeView control

Public Class Frmprog41

Private Sub Frmprog41_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button4.Click
TreeView1.SelectedNode.Remove()

End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button6.Click
MsgBox("You are selected " & TreeView1.SelectedNode.Text)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
TreeView1.ExpandAll()
End Sub

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

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button5.Click
TreeView1.CheckBoxes = True
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button7.Click
TreeView1.HotTracking = True
End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button8.Click
TreeView1.ShowLines = False
End Sub

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button9.Click
TreeView1.ShowPlusMinus = False
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button3.Click
Dim a As String
Dim b As Integer
a = InputBox("enter city ")
b = InputBox("Enter Location : ")
b -= 1
TreeView1.Nodes.Insert(b, a)

End Sub
End Class
OUTPUT:-

67
42)Write a program in VB.NET which will display the functionality of ListView control

68
Public Class frmprog42
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.SelectedItem = "Tile" Then
ListView1.View = View.Tile
ElseIf ComboBox1.SelectedItem = "Details" Then
ListView1.View = View.Details
ElseIf ComboBox1.SelectedItem = "Large Icon" Then
ListView1.View = View.LargeIcon
ElseIf ComboBox1.SelectedItem = "List" Then
ListView1.View = View.List
ElseIf ComboBox1.SelectedItem = "Small Icon" Then
ListView1.View = View.SmallIcon

End If
End Sub

69
Private Sub frmprog42_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
ListView1.View = View.Details
ListView1.Columns.Add("RESTURANT", 190, HorizontalAlignment.Left)
ListView1.Columns.Add("AREA", 90, HorizontalAlignment.Left)
ListView1.Columns.Add("RATING", 90, HorizontalAlignment.Left)
ListView1.Items.Add("GORDHN THAL")
ListView1.Items(0).SubItems.Add("SG RD")
ListView1.Items(0).SubItems.Add("5")
ListView1.Items.Add("TOMATOES")
ListView1.Items(1).SubItems.Add("CG RD")
ListView1.Items(1).SubItems.Add("5")
ListView1.Items.Add("DESI TADKA")
ListView1.Items(2).SubItems.Add("SG RD")
ListView1.Items(2).SubItems.Add("5")
ListView1.Items.Add("PATANG")
ListView1.Items(3).SubItems.Add("nEHRU")
ListView1.Items(3).SubItems.Add("3")
ListView1.Columns.Add("AMBIENCE", 190, HorizontalAlignment.Left)
ListView1.Items(0).SubItems.Add("EXELENT")
ListView1.Items.Add("FREEZLAND")
ListView1.Items(4).SubItems.Add("LAW GARDEN")
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
Dim N As Integer
N = ListView1.Items.Count
ListView1.Items.Add(TextBox1.Text)
ListView1.Items(N).SubItems.Add(TextBox2.Text)
ListView1.Items(N).SubItems.Add(TextBox3.Text)
ListView1.Items(N).SubItems.Add(TextBox4.Text)
End Sub
End Class
OUTPUT:-

70
43)Write a program in VB.NET which will implement the mouse down event and show to
user the location of the mouse in a text box

Imports System.Drawing
Public Class frmprog43

Private Sub frmprog43_MouseDown(ByVal sender As System.Object, ByVal e As


System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
TextBox1.Text = e.X & ", " & e.Y & "."
End Sub

71
Private Sub frmprog43_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub
End Class

OUTPUT:-

IT SHOWS MOUSE LOCATION

44)Write a program in VB.NET which show functionality of checked list box.

Public Class frmprog44

72
Private Sub frmprog44_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub

Private Sub ComboBox4_SelectedIndexChanged(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles ComboBox4.SelectedIndexChanged
Dim I As Integer
Dim S As String
For I = 0 To CheckedListBox1.Items.Count - 1
S = CheckedListBox1.Items.Item(I)
If S.StartsWith(ComboBox4.SelectedItem) = True Then
CheckedListBox1.SetItemChecked(I, True)
Else
CheckedListBox1.SetItemChecked(I, False)

End If
Next
End Sub
End Class
OUTPUT:-

45)Write a program in VB.NET which show functionality of MDI form.

73
Public Class FRMMAINMENU

Private Sub FRMMAINMENU_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
IsMdiContainer=True

End Sub

Private Sub PROGRAM1ToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles PROGRAM1ToolStripMenuItem.Click
Dim obj1 As New Frmprog1
obj1.MdiParent = Me
obj1.Show()
End Sub

Private Sub PROGRAM2ToolStripMenuItem1_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles PROGRAM2ToolStripMenuItem1.Click
Dim obj1 As New Frmprog2
obj1.MdiParent = Me
obj1.Show()
End Sub
End class

74
46)Make application of login form with progess bar.

Public Class LoginForm1


Public I As Integer

Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
Timer1.Enabled = True
Timer1.Start()

End Sub

Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
Me.Close()
End Sub

Private Sub LoginForm1_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
ProgressBar1.Maximum = 100
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Timer1.Tick

ProgressBar1.Increment(10)
If ProgressBar1.Value = 100 Then

75
Timer1.Stop()
MsgBox("COMPLETE")
FRMMAINMENU.Show()

End If
Label1.Text = ProgressBar1.Value
End Sub

End Class

47)Check some mathematical function, String function , date time function using tab order
where you can use 3 tab and apply any min 5 function of each class as separately

48)Write an application in vb.net which has one date time picker as per select index
changed process apply some methods of date and time class like add days , today , now ,
addhours , addminute , isleapyer , daysofmonth. And check in form

49)write an application in vb.net which shows menues and contextmenu on MDI form.

50)Write an application in vb.net which looks like ‘Windows explorer’ having full facility of
drive,directory and file class methods and class utilization

76

You might also like