Prg_1TO25

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

Journal List Solution of (VB.

NET)
US05CBCA04

1) Display a message in a lable on click event of the button.

Public class form 1

Private sub BtnOk_click(byval sender As system.object, byval e As


system.Eventargs) handles BtnOk.click

Lblnm.visible=true

Lblnm.text="Welcome"

end sub

end class

2) Create a simple VB.Net Project. Place a button on the form and show
welcome message on the click of the button using msgbox() function.

Public class form 1

Private sub Btnnm_click(byval sender As system.object, byval e as


system.Eventargs) handles Btnnm.click

msgbox("you entered the word" +Txtnm.text)

end sub

end class
O/P:

3) Accept two numbers using Inputbox on the click of the button and
display SUM of these two numbers using Msgbox.

Public class form 1

Private sub Btnadd_click(byval sender As system.object, byval e as


system.Eventargs) handles Btnadd.click
Dim a, b, c As Integer
a = InputBox("enter the value 1")
b = InputBox("enter the value 2")
c = a + b
MsgBox("you entered the word: " & c)

end sub
end class O/P:
4) Design a form as shown below and perform the operations on the
numbers entered.

Public class form 1

Private sub Btnplus_click(byval sender As system.object, byval e as


system.Eventargs) handles Btnplus.click

Txtans.text = val (Txt1.text)+val( Txt2.text)

End sub

Private sub Btnsub_click(byval sender As system.object, byval e as


system.Eventargs) handles Btnsub.click

Txtans.text = val (Txt1.text)-val( Txt2.text)

End sub

Private sub Btnmul_click(byval sender As system.object, byval e as


system.Eventargs) handles Btnmul.click

Txtans.text = val (Txt1.text)*val( Txt2.text)

End sub

Private sub Btndiv_click(byval sender As system.object, byval e as


system.Eventargs) handles Btndiv.click

Txtans.text = val (Txt1.text)/val( Txt2.text)


End sub

End class

5) Write a program to find weather the given no is Positive, negative or


zero.
Public Class Form1

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


System.EventArgs) Handles Btnno.Click
Dim n As Double
n = Val(Txt1.Text)

If n > 0 Then
MsgBox("This is a Positive Number", vbInformation, "Result")
ElseIf n = 0 Then
MsgBox("This is a Zero Number", vbInformation, "Result")
Else
MsgBox("This is a Negative Number", vbInformation, "Result")
End If

End Sub

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


System.EventArgs) Handles BtnClear.Click
Txt1.Text = ""

End Sub

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


System.EventArgs) Handles BtnExit.Click
Application.Exit()
End Sub
End Class

O/P:
6) Write a program to find the maximum and minimum of given three
numbers.
Public Class Form1

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


System.EventArgs) Handles Btnmin.Click
Dim a, b, c As Integer
a = Val(Txt1.Text)
b = Val(Txt2.Text)
c = Val(Txt3.Text)
If a < b And a < c Then
MsgBox("Minimum Number is :" + a.ToString)
ElseIf b < c Then
MsgBox("Minimum Number is :" + b.ToString)
Else
MsgBox("Minimum Number is :" + c.ToString)
End If
End Sub

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


System.EventArgs) Handles Btnmax.Click
Dim a, b, c As Integer
a = Val(Txt1.Text)
b = Val(Txt2.Text)
c = Val(Txt3.Text)
If a > b And a > c Then
MsgBox("Maximum Number is :" + a.ToString)
ElseIf b > c Then
MsgBox("Maximum Number is :" + b.ToString)
Else
MsgBox("Maximum Number is :" + c.ToString)
End If
End Sub

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


System.EventArgs) Handles Btnexit.Click
Application.Exit()
End Sub
End Class

O/P:
7) Develop VB.NET application which calculates the simple interest =
p*r*n / 100 and compound interest = p*(1+r/100)^n using textbox. In the
same application take another form which calculates area and
circumference of circle by declaring Pi as constant in module.
Public Class Form1
'p=principle of amount
'r=rate of amount
'n=number of year
Private Sub BtnSI_Click(sender As Object, e As EventArgs) Handles Button1.Click
'p * r * n / 100
TxtResult.Text = Val(Txtprinciple.Text) * (TxtRate.Text) * (TxtNo.Text) / 100
End Sub

Private Sub BtnCI_Click(sender As Object, e As EventArgs) Handles Button2.Click


' p * (1 + r / 100) ^ n
TxtResult.Text = Val(Txtprinciple.Text) * (1 + Val(TxtRate.Text) / 100) ^
Val(TxtNo.Text)
End Sub

Dim pi As Double = 3.14


Private Sub Btncircle_Click(sender As Object, e As EventArgs) Handles
Btncircle.Click
Dim cir As Integer
Dim r As Double
r = InputBox("Enter value of Rate of Amount :")
cir = pi * r * r
MsgBox(cir, , "Circle")
End Sub

Private Sub Btncircumference_Click(sender As Object, e As EventArgs) Handles


Btncircumference.Click
' C=2πr
Dim cir As Integer
Dim r As Double
r = InputBox("Enter Value Of Rate of Amount :")
cir = 2 * pi * r
MsgBox(cir, , "Circle")
End Sub
End Class O/P:
8) Design a form as shown below and display the array in ascending and
descending order.

Public Class Form1


Dim a(10) As Integer
Private Sub Btnno_Click(sender As Object, e As EventArgs) Handles Btnno.Click
Dim i, j, k As Integer
For i = 1 To Val(Txtno.Text) - 1
a(i) = InputBox("Enter the Element :")
Lstbox1.Items.Add(a(i))
Next
For i = 0 To Val(Txtno.Text) - 2
For j = i + 1 To Val(Txtno.Text) - 1
If a(i) > a(j) Then
k = a(i)
a(i) = a(j)
a(j) = k
End If
Next
Next
For i = 0 To Val(Txtno.Text) - 1
Lstbox2.Items.Add(a(i))
Next
For i = 0 To Val(Txtno.Text) - 2
For j = i + 1 To Val(Txtno.Text) - 1
If a(i) < a(j) Then
k = a(i)
a(i) = a(j)
a(j) = k
End If
Next
Next
For i = 0 To Val(Txtno.Text) - 1
Lstbox3.Items.Add(a(i))
Next
End Sub
End Class
O/P:

9). Design a VB form as shown below to read the student data and generate
the mark-sheet data. Clear the data when user clicks the “Clear” button.
When user click on “Exit” then end the execution.

Public Class Form1

Private Sub BtnGenerate_Click(sender As Object, e As EventArgs) Handles


BtnGenerate.Click
Dim a As Integer = 0
Txttot.Text = Val(Txtsub1.Text) + Val(Txtsub2.Text) + Val(Txtsub3.Text) +
Val(Txtsub4.Text) + Val(Txtsub5.Text) + Val(Txtsub6.Text)
If Val(Txtsub1.Text) < 35 Then
a = a + 1
End If
If Val(Txtsub2.Text) < 35 Then
a = a + 1
End If
If Val(Txtsub3.Text) < 35 Then
a = a + 1
End If
If Val(Txtsub4.Text) < 35 Then
a = a + 1
End If
If Val(Txtsub5.Text) < 35 Then
a = a + 1
End If
If Val(Txtsub6.Text) < 35 Then
a = a + 1
End If
If a = 1 Or a = 2 Then
Txtper.Text = "--"
Txtgrade.Text = "ATKT"
End If
If a >= 3 Then
Txtper.Text = "--"
Txtgrade.Text = "FAIL"
End If
If a = 0 Then
Txtper.Text = Val(Txttot.Text) / 6
If Val(Txtper.Text) >= 70 Then
Txtgrade.Text = "Dist"
End If
If Val(Txtper.Text) >= 60 And Val(Txtper.Text) < 70 Then
Txtgrade.Text = "First"
End If
If Val(Txtper.Text) >= 50 And Val(Txtper.Text) < 60 Then
Txtgrade.Text = "Second"
End If
If Val(Txtper.Text) >= 35 And Val(Txtper.Text) < 50 Then
Txtgrade.Text = "pass"
End If
End If
End Sub

Private Sub BtnExit_Click(sender As Object, e As EventArgs) Handles BtnExit.Click


Application.Exit()
End Sub

Private Sub BtnClear_Click(sender As Object, e As EventArgs) Handles


BtnClear.Click
Txtno.Text = ""
Txtnm.Text = ""
Txtsub1.Text = ""
Txtsub2.Text = ""
Txtsub3.Text = ""
Txtsub4.Text = ""
Txtsub5.Text = ""
Txtsub6.Text = ""
Txttot.Text = ""
Txtper.Text = ""
Txtgrade.Text = ""
End Sub

End Class
O/P:

13) Design the digital watch using Timer Control.


Public Class Form1

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


Handles MyBase.Load

Timer1.Start()

End Sub

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


System.EventArgs) Handles Timer1.Tick

LblTimer.Text = TimeOfDay

End Sub

End Class

O/P:
16) Design the following form:

Public Class Form1

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


System.EventArgs) Handles RdbUpper.CheckedChanged

If RdbUpper.Checked = True Then

Txtoutput.Text = UCase(TxtString.Text)

End If

End Sub

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


System.EventArgs) Handles RdbLower.CheckedChanged

If RdbLower.Checked = True Then

Txtoutput.Text = LCase(TxtString.Text)

End If

End Sub

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


System.EventArgs) Handles RdbLength.CheckedChanged

If RdbLength.Checked = True Then

Txtoutput.Text = Str(Len(TxtString.Text))

End If

End Sub

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


System.EventArgs) Handles RdbReverse.CheckedChanged

If RdbReverse.Checked = True Then

Txtoutput.Text = StrReverse(TxtString.Text)
End If

End Sub

End Class

O/P:

10) Develop an application that demonstrates CUT, COPY AND PASTE


command.
Public Class Form1

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


Handles Btncut.Click
richtextbox1.cut()
End Sub

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


Handles Btncopy.Click
richtextbox1.copy()
End Sub

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


Handles Btnpaste.Click
richtextbox1.paste()
End Sub
End Class

O/P:
11) Design the following calculator.
O/P:

Public Class Form1


Dim temp, a As Double
Dim op As String
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button6.Click
If temp = 0 Then
TextBox1.Text = TextBox1.Text + "5"
Else
TextBox1.Text = "5"
temp = 0
End If
End Sub

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


System.EventArgs) Handles Button14.Click
If TextBox1.Text <> "" Then
TextBox1.Text = TextBox1.Text + "0"
End If
End Sub

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


System.EventArgs) Handles Button17.Click
TextBox1.Clear()
'TextBox1.Text="";
End Sub

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


System.EventArgs) Handles Button4.Click
a = TextBox1.Text
op = "+"
temp = 1
End Sub

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


Handles MyBase.Load
temp = 0
End Sub
Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button18.Click
'a = TextBox1.Text
If op = "+" Then
TextBox1.Text = a + TextBox1.Text
ElseIf op = "-" Then
TextBox1.Text = a - TextBox1.Text
ElseIf op = "*" Then
TextBox1.Text = a * TextBox1.Text
ElseIf op = "/" Then
TextBox1.Text = a / TextBox1.Text
End If
End Sub

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


System.EventArgs) Handles Button8.Click
a = TextBox1.Text
op = "*"
temp = 1
End Sub

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


System.EventArgs) Handles Button12.Click
a = TextBox1.Text
op = "/"
temp = 1
End Sub

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


System.EventArgs) Handles Button16.Click
a = TextBox1.Text
op = "-"
temp = 1
End Sub

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


System.EventArgs) Handles Button3.Click
If temp = 0 Then
TextBox1.Text = TextBox1.Text + "9"
Else
TextBox1.Text = "9"
temp = 0
End If
End Sub

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


System.EventArgs) Handles Button2.Click
If temp = 0 Then
TextBox1.Text = TextBox1.Text + "8"
Else
TextBox1.Text = "8"
temp = 0
End If
End Sub

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


System.EventArgs) Handles Button1.Click
If temp = 0 Then
TextBox1.Text = TextBox1.Text + "7"
Else
TextBox1.Text = "7"
temp = 0
End If
End Sub

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


System.EventArgs) Handles Button15.Click
If TextBox1.Text = "" Then
TextBox1.Text = "0."
Else
TextBox1.Text = TextBox1.Text + "."
End If
End Sub

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


System.EventArgs) Handles Button13.Click
If TextBox1.Text.Substring(0, 1) = "-" Then
TextBox1.Text = TextBox1.Text.Remove(0, 1)
Else
TextBox1.Text = TextBox1.Text.Insert(0, "-")
End If
End Sub

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


System.EventArgs) Handles Button9.Click
If temp = 0 Then
TextBox1.Text = TextBox1.Text + "1"
Else
TextBox1.Text = "1"
temp = 0
End If
End Sub

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


System.EventArgs) Handles Button10.Click
If temp = 0 Then
TextBox1.Text = TextBox1.Text + "2"
Else
TextBox1.Text = "2"
temp = 0
End If
End Sub

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


System.EventArgs) Handles Button11.Click
If temp = 0 Then
TextBox1.Text = TextBox1.Text + "3"
Else
TextBox1.Text = "3"
temp = 0
End If
End Sub

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


System.EventArgs) Handles Button5.Click
If temp = 0 Then
TextBox1.Text = TextBox1.Text + "4"
Else
TextBox1.Text = "4"
temp = 0
End If
End Sub

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


System.EventArgs) Handles Button7.Click
If temp = 0 Then
TextBox1.Text = TextBox1.Text + "6"
Else
TextBox1.Text = "6"
temp = 0
End If
End Sub

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


System.EventArgs) Handles TextBox1.TextChanged

End Sub
End Class

15) Design the following form.

Public Class Form1


Dim i, j, k, f As Integer

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


Handles MyBase.Load
ComboBox1.SelectedIndex = 0
ComboBox2.SelectedIndex = 0
ListBox1.Items.Clear()
End Sub
Public Sub xyz()
ListBox1.Items.Clear()

If RbtnOdd.Checked = True Then


i = ComboBox1.Text
j = ComboBox2.Text
For k = i To j
If k Mod 2 <> 0 Then
ListBox1.Items.Add(k)
End If
Next
End If

If RbtnEven.Checked = True Then


i = ComboBox1.Text
j = ComboBox2.Text
For k = i To j
If k Mod 2 = 0 Then
ListBox1.Items.Add(k)
End If
Next
End If

If RbtnPrime.Checked = True Then


i = ComboBox1.Text
j = ComboBox2.Text

While i <= j
f = 0
For k = 2 To i / 2
If i Mod k = 0 Then
f = 1
End If
Next
If f = 0 Then
ListBox1.Items.Add(i)
End If
i = i + 1
End While
End If
End Sub

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


System.EventArgs) Handles RbtnPrime.CheckedChanged
Call xyz()

End Sub

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


System.EventArgs) Handles RbtnOdd.CheckedChanged
Call xyz()
End Sub

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


System.EventArgs) Handles RbtnEven.CheckedChanged
Call xyz()
End Sub
End Class

O/P:
17) Develop the following form. When user clicks add button add the name in
list box (Friend), using list box (Friend) enter selected name in another list
box (Invite), also remove-selected name from list box.

Public Class Form1

Private Sub BtnG_Click(sender As Object, e As EventArgs) Handles BtnG.Click


If ListBox1.SelectedIndex < 0 Then
MsgBox("Please a select item first")
End If
ListBox2.Items.Add(ListBox1.SelectedItem)
ListBox1.Items.Remove(ListBox2.SelectedItem)
End Sub

Private Sub BtnGG_Click(sender As Object, e As EventArgs) Handles BtnGG.Click


Dim i, j As Integer
i = 0
j = ListBox1.Items.Count
While i < j
ListBox1.SelectedIndex = i
ListBox2.Items.Add(ListBox1.SelectedItem)
i = i + 1
End While
ListBox1.Items.Clear()
End Sub

Private Sub BtnL_Click(sender As Object, e As EventArgs) Handles BtnL.Click


If ListBox2.SelectedIndex < 0 Then
MsgBox("Please a select item first")
End If
ListBox1.Items.Add(ListBox2.SelectedItem)
ListBox2.Items.Remove(ListBox1.SelectedItem)
End Sub

Private Sub BtnLL_Click(sender As Object, e As EventArgs) Handles BtnLL.Click


Dim i, j As Integer
i = 0
j = ListBox2.Items.Count
While i < j
ListBox2.SelectedIndex = i
ListBox1.Items.Add(ListBox2.SelectedItem)
i = i + 1
End While
ListBox2.Items.Clear()
End Sub

Private Sub BtnAdd_Click(sender As Object, e As EventArgs) Handles BtnAdd.Click


If TextBox1.Text = "" Then
MsgBox("Please enter name:")
End If
ListBox1.Items.Add(TextBox1.Text)
TextBox1.Text = ""
TextBox1.Focus()
End Sub

Private Sub BtnRemove_Click(sender As Object, e As EventArgs) Handles


BtnRemove.Click
ListBox1.Items.Remove(ListBox1.SelectedItem)
ListBox2.Items.Remove(ListBox2.SelectedItem)
End Sub

Private Sub BtnExit_Click(sender As Object, e As EventArgs) Handles BtnExit.Click


Me.Close()
End Sub
End Class

O/P:
18) Develop following form. When user clicks on Submit button then all
information will be printed in following textbox. When user clicks on Clear
then all textboxes will clear. When user clicks on Exit button then
application will be closed.

Public Class Form1


Dim fname, lname, address, status, gender, english, d As String
Private Sub BtnExit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
Me.Close()
End Sub
Private Sub BtnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
fname = TxtFnm.Text
lname = TxtLnm.Text
address = TxtAddress.Text

If RdbMarried.Checked = True Then


status = "Maried"
ElseIf RdbUnmarried.Checked = True Then
status = "Unmaried"
End If

If RdbMale.Checked = True Then


gender = "Male"
ElseIf RdbFemale.Checked = True Then
gender = "Female"
End If

If ChkRead.Checked = True Then


english = "Read"
End If
If ChkWrite.Checked = True Then
english = "Write"
End If
If ChkSpeak.Checked = True Then
english = "Speak"
End If
d = DateTimePicker1.Text

TxtAll.Text = fname + " " + lname + ", " + address + ", " + status + ", " +
gender + ", " + english + ", " + d
End Sub

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


Handles MyBase.Load
DateTimePicker1.CustomFormat = "dd-MM-yyyy"
End Sub

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


System.EventArgs) Handles Button2.Click
TxtFnm.Clear()
TxtLnm.Clear()
TxtAddress.Clear()
TxtAll.Clear()
End Sub
End Class

O/P:
19) Design following Form which shows use of Picture box.

O/P:

Public Class Form1

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


System.EventArgs) Handles Button1.Click
OpenFileDialog1.ShowDialog()
PictureBox1.ImageLocation = OpenFileDialog1.FileName()
End Sub

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


System.EventArgs) Handles Button2.Click
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
End Sub
End Class

20) Design following Form which shows use of Horizontal and Vertical
Scroll Bar.

O/P:

Public Class Form1


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
HScrollBar1.Minimum = 25
HScrollBar1.Maximum = 300
VScrollBar1.Minimum = 25
VScrollBar1.Maximum = 300
LblScroll.Text = "(" & HScrollBar1.Value & ", " & VScrollBar1.Value & ")"
LblScroll.Location = New Point(HScrollBar1.Value, VScrollBar1.Value)
End Sub

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


System.Windows.Forms.ScrollEventArgs) Handles HScrollBar1.Scroll
LblScroll.Text = "(" & HScrollBar1.Value & ", " & VScrollBar1.Value & ")"
LblScroll.Location = New Point(HScrollBar1.Value, VScrollBar1.Value)
End Sub

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


System.Windows.Forms.ScrollEventArgs) Handles VScrollBar1.Scroll
LblScroll.Text = "(" & HScrollBar1.Value & ", " & VScrollBar1.Value & ")"
LblScroll.Location = New Point(HScrollBar1.Value, VScrollBar1.Value)
End Sub
End Class

21) Design following Form which shows use of Checked List box.

Public Class Form1

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


System.EventArgs) Handles Button1.Click
CheckedListBox1.Items.Add(TxtItem.Text)
TxtItem.Clear()

End Sub

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


System.EventArgs) Handles Button2.Click
Dim s As String
s = ""
For i = 0 To CheckedListBox1.CheckedItems.Count - 1
s = s + CheckedListBox1.CheckedItems(i).ToString()
Next

Txtop.Text = s
End Sub
Private Sub BtnUnChecked_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim s As String
s = ""
For i = 0 To CheckedListBox1.Items.Count - 1
If CheckedListBox1.GetItemCheckState(i) =
CheckState.Unchecked Then
s = s + CheckedListBox1.Items(i).ToString()
End If
Next

Txtop.Text = s
End Sub
End Class

O/P:

22) Create a following form and insert a linked label on the form.
Public Class Form1

Private Sub LinkLabel1_LinkClicked(sender As Object, e As


LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
Me.Hide()
Form2.Show()
End Sub

O/P:
23) Design following Form which shows use of Tree view control.

O/P:

Public Class Form1


Dim t As Integer

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


System.EventArgs) Handles Button1.Click
If t = 0 Then
TreeView1.Nodes.Add(TxtValue.Text)
Else
TreeView1.SelectedNode.Nodes.Add(TxtValue.Text)
End If
TxtValue.Clear()
End Sub

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


System.EventArgs) Handles Button2.Click
TreeView1.SelectedNode.Remove()
End Sub

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


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

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


System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
t = 1
End Sub
End Class
24) Design following Form which shows use of various dialog boxes, give
respective message.

Public Class Form1

Private Sub BtnColor_Click(sender As Object, e As EventArgs) Handles


BtnColor.Click
ColorDialog1.ShowDialog()
RichTextBox1.SelectionColor = ColorDialog1.Color
End Sub

Private Sub BtnFont_Click(sender As Object, e As EventArgs) Handles BtnFont.Click


FontDialog1.ShowDialog()
RichTextBox1.SelectionFont = FontDialog1.Font
End Sub

Private Sub BtnExit_Click(sender As Object, e As EventArgs) Handles BtnExit.Click


Application.Exit()
Me.Close()
End Sub
End Class

O/P:
25) Design the Following Notepad using Menu editor & MDI form.
• Edit – Cut, Copy, Paste
• Format – Font, Bold, Italic, Underline, Color(submenu contains 2 options :
BackColor, Text Color)
• Find & Replace facility.

Public Class Form1


Private Sub CutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles
CutToolStripMenuItem.Click
RichTextBox1.Cut()
End Sub

Private Sub CopyToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles


CopyToolStripMenuItem.Click
RichTextBox1.Copy()
End Sub

Private Sub PasteToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles


PasteToolStripMenuItem.Click
RichTextBox1.Paste()
End Sub

Private Sub FontToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles


FontToolStripMenuItem.Click
FontDialog1.ShowDialog()
RichTextBox1.SelectionFont = FontDialog1.Font
End Sub

Private Sub BoldToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles


BoldToolStripMenuItem.Click
RichTextBox1.SelectionFont = New
System.Drawing.Font(RichTextBox1.SelectionFont, FontStyle.Bold)
End Sub

Private Sub ItalicToolStripMenuItem_Click(sender As Object, e As EventArgs)


Handles ItalicToolStripMenuItem.Click
RichTextBox1.SelectionFont = New
System.Drawing.Font(RichTextBox1.SelectionFont, FontStyle.Italic)
End Sub

Private Sub UnderLineToolStripMenuItem_Click(sender As Object, e As EventArgs)


Handles UnderLineToolStripMenuItem.Click
RichTextBox1.SelectionFont = New
System.Drawing.Font(RichTextBox1.SelectionFont, FontStyle.Underline)
End Sub

Private Sub BackGroundToolStripMenuItem_Click(sender As Object, e As EventArgs)


Handles BackGroundToolStripMenuItem.Click
ColorDialog1.ShowDialog()
RichTextBox1.BackColor = ColorDialog1.Color
End Sub

Private Sub TextColorToolStripMenuItem_Click(sender As Object, e As EventArgs)


Handles TextColorToolStripMenuItem.Click
ColorDialog1.ShowDialog()
RichTextBox1.SelectionColor = ColorDialog1.Color
End Sub

Private Sub ViewToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles


ViewToolStripMenuItem.Click
Dim str As String
str = InputBox("Enter Find Word...!")
RichTextBox1.Find(str)
End Sub

Private Sub HelpToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles


HelpToolStripMenuItem.Click
Dim str1, str2, rtb As String
str1 = InputBox("Enter Find Word...!")
str2 = InputBox("Enter Replace Word...!")
rtb = RichTextBox1.Text
RichTextBox1.Text = rtb.Replace(str1, str2)
End Sub
End Class

O/P:

You might also like