Friday, November 24, 2023

Visual Basic .Net Programming

 Program 1 Sum of Two Numbers


Form Design for Sum of Two Numbers
Coding for OK Button
Dim a, b, c as integer
a=textbox1.text
b=textbox2.text
c=a + b
textbox3.text=c
-------------------------------------
Coding for Clear Button
textbox1.text=" "
textbox2.tetx=" "
textbox3.text  " "
------------------------------------
Coding for End Button
End
----------------------------------------

Program 2 Calculator Program


Coding for Sum Button
dim a, b, c as integer
a=textbox1.text
b=textbox2.text
c=a+b
textbox3.text=c

Coding for Subtraction Button
dim a, b, c as integer
a=textbox1.text
b=textbox2.text
c=a-b
textbox3.text=c

Coding for Multiplication Button
dim a, b, c as integer
a=textbox1.text
b=textbox2.text
c=a*b
textbox3.text=c

Coding for Division Button
dim a, b, c as integer
a=textbox1.text
b=textbox2.text
c=a/b
textbox3.text=c

Coding for Clear Button
textbox1.text=" "
textbox2.text=" "
textbox3.text=" "
textbox4.text=" "

Coding for End Button
end

Program 3 Write "MLC" in Form Load 

Coding for Form Load
Label1.text="WEL_COME TO MLC "
Label1.backcolor=color.aqua
Label1.forecolor=color.red
msgbox("Form Load Event ")

Program 4 Area of Circle


Coding for calculate Button

Public Class Form4
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim r As Integer
        Dim ans As Double
        r = Val(TextBox1.Text)
        ans = 3.14 * r * r
        TextBox2.Text = ans
    End Sub

Coding for Clear button

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Text = ""
        TextBox2.Text = ""
    End Sub

Coding for End Button 

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        End
    End Sub
End Class

Program 5 Volume of Cylinder 3.14*r*r*h


Coding for calculate the Volume of Cylinder
Public Class Form5
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim r, h As Integer
        Dim volume As Double
        r = TextBox1.Text
        h = TextBox2.Text
        volume = 3.14 * r * r * h
        MsgBox(volume)
    End Sub
Coding for Clear Button
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Text = ""
        TextBox2.Text = ""
    End Sub
Coding for End Button
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        End
    End Sub
End Class


Program 6 Write a Program for Login Page

Coding for Click Here Button
Public Class Form6
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim a, b As String
        a = "MLC"
        b = "KORBA"
        If a = TextBox1.Text And b = TextBox2.Text Then
            MsgBox("Successfully Login")
        ElseIf TextBox1.Text = "" Or TextBox2.Text = "" Then
            MsgBox("Login Unsuccessfully")
        ElseIf a <> TextBox1.Text Or b <> TextBox2.Text Then
            MsgBox("Login Unsuccessfully")
        End If
    End Sub
End Class

Program 7 Compare Two Numbers


Coding for Compare Button
Public Class Form7

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim a, b As Integer
        a = TextBox1.Text
        b = TextBox2.Text
        If a > b Then
            MsgBox("First Number is Greatest ")
        Else
            MsgBox("Second Number is Greatest")
        End If
    End Sub
End Class

Program 8 Compare of Three Numbers

Coding for Compare of Three Numbers
Public Class Form8

    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 = TextBox3.Text
        If (a > b) And (a > c) Then
            MsgBox("A is Greatest")
        ElseIf (b > c) Then
            MsgBox("B is Greatest")
        Else
            MsgBox("C is Greatest")
        End If
    End Sub

Coding for Clear Button
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
    End Sub

Coding for End Button
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        End
    End Sub
End Class

Program 9 Check the Number is Odd or Even Number


Coding for Check Button
Public Class Form9

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim num As Integer
        num = TextBox1.Text
        If num Mod 2 = 0 Then
            MsgBox("Even Number ")
        Else
            MsgBox("Odd Number")
        End If
    End Sub
End Class

Program 10 Coffee Shop


Coding for Total Button
Public Class Form11

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim tea, coffee, samosa, dosa, gupchup, pizza, total
        tea = 10
        coffee = 20
        samosa = 15
        dosa = 50
        gupchup = 20
        pizza = 120
        total = 0
        If RadioButton1.Checked = True Then
            total = total + tea
        Else
            total = total + coffee
        End If
        If CheckBox1.Checked = True Then
            total = total + samosa
        End If
        If CheckBox2.Checked Then
            total = total + gupchup
        End If
        If CheckBox3.Checked = True Then
            total = total + dosa
        End If
        If CheckBox4.Checked = True Then
            total = total + pizza
        End If
        MsgBox(total)
    End Sub
    End Class

Program 11 Even Number 1-20, Print Number 20-1, Print Odd Number 1-20, Print Odd Number 20-1, Print 1-20, Print 20-1

Coding for Print Even Number 1-20 Button
Public Class Form12
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim num As Integer
        For num = 0 To 20 Step 2
            ListBox1.Items.Add(num)
        Next
    End Sub
Coding for Print Even Number 20-1 Button
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim num As Integer
        For num = 20 To 0 Step -2
            ListBox1.Items.Add(num)
        Next
    End Sub
Coding for Print Odd Number 1-20 Button
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim num As Integer
        For num = 1 To 20 Step 2
            ListBox1.Items.Add(num)
        Next
    End Sub

Coding for Print Odd Number 20-1 Button
 Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim num As Integer
        For num = 19 To 1 Step -2
            ListBox1.Items.Add(num)
        Next
    End Sub
Coding for Print Number 1-20 Button

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim num As Integer
        For num = 1 To 20
            ListBox1.Items.Add(num)
        Next
    End Sub
Coding for Print Number 20-1 Button

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Dim num As Integer
        For num = 20 To 1 Step -1
            ListBox1.Items.Add(num)
        Next
    End Sub
Coding for Clear Button

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        ListBox1.Items.Clear()
    End Sub
End Class

Program 12 Factorial of given Number


Coding for Click Button
Public Class Form13

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim num, i, fact As Integer
        fact = 1
        num = TextBox1.Text
        For i = 1 To num
            fact = fact * i

        Next
        MsgBox(fact)
    End Sub
End Class

Program 13 Print Number 1-30 and sum them



Coding for Sum Button
Public Class Form14

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim num, sum As Integer
        sum = 0
        For num = 1 To 30
            ListBox1.Items.Add(num)
            sum = sum + num
        Next
        MsgBox(sum & "")
    End Sub
End Class
Program 14 Square of Less then 50


Coding for Perfect Square Button
Public Class Form15
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim num As Integer
        num = 1
        While (num * num < 50)
            ListBox1.Items.Add(num * num)
            num = num + 1
        End While
           End Sub
End Class

Program 15 Find Even and Odd Number of given Number and Count them

Coding for Find Even/Odd Button
Public Class Form2
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim num, i, odd, even As Integer
        num = InputBox("How many numbers you want ")
        For i = 1 To num
        If i Mod 2 = 0 Then
                MsgBox("Even Number " & i)
                even = even + 1
            Else
                MsgBox("Odd Number " & i)
                odd = odd + 1
            End If
        Next
        MsgBox("Total Even Number=" & even & " & Total Odd Number=" & odd)
    End Sub
End Class
Program 16 Find Elements Position in List

Public Class Form10

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim a(5) As Double
        Dim item As Double
        Dim i As Integer
        For i = 1 To 5
            a(i) = InputBox("Enter 5 Elements")
        Next

        item = InputBox("Which Elements you want ")
        For i = 1 To 5
            If a(i) = item Then
                MsgBox(item & " Found at Position " & i)
                Exit For
            End If
        Next
        If i = 6 Then
            MsgBox(item & "Does not Exist ")

        End If
    End Sub
End Class

Program 17 Combo box Tools  

Coding for Form Load 
Public Class Form13
    Private Sub Form13_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = "MLC KORBA"
    End Sub
Coding for >> Button1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If ComboBox1.SelectedIndex > -1 Then
            Dim sidx As Integer
            sidx = ComboBox1.SelectedIndex
            Dim sitem As Object
            sitem = ComboBox1.SelectedItem
            ListBox1.Items.Add(sitem)
        End If
    End Sub
Coding for Sort Button3
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        ComboBox1.Sorted = True
    End Sub
Coding for Clear Button4
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        ListBox1.Items.Clear()
    End Sub
Coding for Fill Button2
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ComboBox1.Items.Clear()
        ComboBox1.Items.Add("Gardening")
        ComboBox1.Items.Add("Reading")
        ComboBox1.Items.Add("Dancing")
        ComboBox1.Items.Add("Music")
        ComboBox1.Items.Add("Watching TV")
        ComboBox1.Text = "Selected List...."
    End Sub
Coding for combobox1
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Label2.Text = ComboBox1.SelectedIndex.ToString()
    End Sub
End Class

Program 18 Checklistbox Tool
Coding for Form Load
Public Class Form17
    Private Sub Form17_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = "MLC KORBA"
        CheckedListBox1.Items.Add("DCA")
        CheckedListBox1.Items.Add("PGDCA")
        CheckedListBox1.Items.Add("BCA")
        CheckedListBox1.Items.Add("Tally")
        Label1.Text = "Choose one or more Courses "
        Button1.Text = "Select"
        Button2.Text = "Exit"
    End Sub
Coding for Button1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim ch As New System.Text.StringBuilder
        dim item as object
        For Each item In CheckedListBox1.CheckedItems
            ch.Append(item)
            ch.Append(" ")
        Next
        MessageBox.Show("Your Selected Items " & ch.ToString())
    End Sub
Coding for Button2
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        End
    End Sub
End Class
Program 19
Public Class Form17

    Private Sub HScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar1.Scroll
        Label1.Text = HScrollBar1.Value.ToString
        End Sub

    Private Sub VScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles VScrollBar1.Scroll
        Label2.Text = VScrollBar1.Value.ToString
        End Sub
End Class

Program 20
Public Class Form18

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim dp As Date = DateTimePicker1.Value
        Dim dp1 As Date = DateTimePicker2.Value
        Dim result As TimeSpan = dp.Subtract(dp1)
        Dim ds As Integer = result.TotalDays
        TextBox1.Text = ds
        TextBox1.ForeColor = Color.Red
        MsgBox("Days=" & ds)
    End Sub
End Class

Program 21



Public Class Form19

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        PictureBox2.Image = PictureBox1.Image

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        PictureBox1.Visible = False
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        PictureBox1.Visible = True

    End Sub
End Class

Program 22 Notepad Program



Public Class Form20
Coding For New
    Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
        If RichTextBox1.Modified Then
            Dim a As MsgBoxResult
            a = MsgBox("Do you want to changes ", MsgBoxStyle.YesNoCancel, "New Document")
            If a = MsgBoxResult.No Then
                RichTextBox1.Clear()
            ElseIf a = MsgBoxResult.Cancel Then
            ElseIf MsgBoxResult.Yes Then
                SaveFileDialog1.ShowDialog()
                My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, RichTextBox1.Text, False)
                RichTextBox1.Clear()
            End If
        Else
            RichTextBox1.Clear()
        End If
    End Sub
Coding for Open
    Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
        If RichTextBox1.Modified Then
            Dim ask As MsgBoxResult
            ask = MsgBox("Do You want to Save the file ", MsgBoxStyle.YesNoCancel, "OPen Document")
            If ask = MsgBoxResult.No Then
                OpenFileDialog1.ShowDialog()
                RichTextBox1.Text = My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName)
            ElseIf ask = MsgBoxResult.Cancel Then
            ElseIf ask = MsgBoxResult.Yes Then
                My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, RichTextBox1.Text, False)
                RichTextBox1.Clear()
            End If
        Else
            OpenFileDialog1.ShowDialog()
            Try
                RichTextBox1.Text = My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName)
            Catch ex As Exception
            End Try
        End If
    End Sub
Coding for Save
    Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
        SaveFileDialog1.ShowDialog()
        If My.Computer.FileSystem.FileExists(SaveFileDialog1.FileName) Then
            Dim ask As MsgBoxResult
            ask = MsgBox("File already exist you like to replace it ", MsgBoxStyle.YesNoCancel, "File Exist")
            If ask = MsgBoxResult.No Then
                SaveFileDialog1.ShowDialog()
                If ask = MsgBoxResult.Yes Then
                    My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, RichTextBox1.Text, False)
                End If
            Else
                Try
                    My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, RichTextBox1.Text, False)
                Catch ex As Exception
                End Try
            End If
        End If
    End Sub
Coding for Exit
    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        End
        Me.Close()
    End Sub
Coding for Cut
    Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CutToolStripMenuItem.Click
        RichTextBox1.Cut()
    End Sub
Coding for Paste
    Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteToolStripMenuItem.Click
        RichTextBox1.Paste()
    End Sub
Coding for Copy
    Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem.Click
        RichTextBox1.Copy()
    End Sub
Coding for Undo
    Private Sub CopyToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem1.Click
        RichTextBox1.Undo()
    End Sub
Coding for Redo
    Private Sub PasteToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteToolStripMenuItem1.Click
        RichTextBox1.Redo()
    End Sub
Coding for Font
    Private Sub FontToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FontToolStripMenuItem1.Click
        FontDialog1.ShowDialog()
        RichTextBox1.SelectionFont = FontDialog1.Font
    End Sub
Coding for Fore Color
    Private Sub ForeColorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ForeColorToolStripMenuItem.Click
        ColorDialog1.ShowDialog()
        RichTextBox1.ForeColor = ColorDialog1.Color
    End Sub
Coding for Left Alignment
    Private Sub LeftToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        RichTextBox1.SelectionAlignment = HorizontalAlignment.Left
    End Sub
Coding for Right Alignment
    Private Sub RightToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        RichTextBox1.SelectionAlignment = HorizontalAlignment.Right
    End Sub
Coding for Center Alignment
    Private Sub CenterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        RichTextBox1.SelectionAlignment = HorizontalAlignment.Center
    End Sub
Coding for Bullet Yes

    Private Sub YesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        RichTextBox1.SelectionBullet = True
    End Sub
Coding for Bullet No
    Private Sub NoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        RichTextBox1.SelectionBullet = False
    End Sub

 Coding for Zoom 2
    Private Sub ToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem2.Click
        RichTextBox1.ZoomFactor = 2
    End Sub
Coding for Zoom 4
    Private Sub ToolStripMenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem3.Click
        RichTextBox1.ZoomFactor = 4
    End Sub
Coding for Zoom 8
    Private Sub ToolStripMenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem4.Click
        RichTextBox1.ZoomFactor = 8
    End Sub
Coding for Zoom 10
    Private Sub ToolStripMenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem5.Click
        RichTextBox1.ZoomFactor = 10
    End Sub
   Coding for Back Color    
    Private Sub BackColorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BackColorToolStripMenuItem.Click
        ColorDialog1.ShowDialog()
        RichTextBox1.BackColor = ColorDialog1.Color
    End Sub

Coding for Find
    Private Sub FindToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FindToolStripMenuItem1.Click
        Dim a, b As String
        a = InputBox("Enter text to Find ")
        b = InStr(RichTextBox1.Text, a)
        If b Then
            RichTextBox1.SelectionStart = b - 1
            RichTextBox1.SelectionLength = Len(a)
        Else
            MsgBox("Text not Found !!")

        End If

    End Sub
    End Class
Program 23 Timer 

Public Class Form21
    Dim counter As Single
Coding for Form Load
    Private Sub Form21_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                Timer1.Interval = 1000
        Timer1.Enabled = False
        TextBox1.Text = Timer1.Interval
        counter = 0
        With Label1
            .Text = "0"
            .BorderStyle = BorderStyle.Fixed3D
            .BackColor = Color.Aqua
            .Font = New Font("Courier", 22, FontStyle.Bold)
        End With
    End Sub
Coding for Button 1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Interval = TextBox1.Text
        Timer1.Enabled = True
    End Sub
Coding for Button 2
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Timer1.Enabled = False
    End Sub
Coding for Timer 1
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Beep()
        counter = counter + 1
        Label1.Text = counter
    End Sub
End Class
Program 23 Treeview Tools

Public Class Form22

Coding for Add Root Node Button
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim node As New TreeNode(TextBox1.Text)
        'add root node
        TreeView1.Nodes.Add(node)
    End Sub
Coding for Add Child Node Button

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim node As New TreeNode(TextBox1.Text)
        'add child node
        TreeView1.SelectedNode.Nodes.Add(node)

    End Sub
End Class

Program 23 Listview Tool


Coding for Add Button
Public Class Form23
    Dim c As Integer = 0
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If RadioButton1.Checked = True Then
            ListView1.Items.Add("Plain Rice")
        ElseIf RadioButton2.Checked = True Then
            ListView1.Items.Add("Pulao")
        Else
            ListView1.Items.Add("Biriyani")
        End If
        If RadioButton4.Checked = True Then
            ListView1.Items(c).SubItems.Add("Tea")
        ElseIf RadioButton5.Checked = True Then
            ListView1.Items(c).SubItems.Add("Coffee")
        Else
            ListView1.Items(c).SubItems.Add("Cold Drinks")
        End If
        ListView1.Items(c).SubItems.Add(TextBox1.Text)
        c = c + 1
    End Sub
End Class

Program 24 Module
Adding a Module
Step 1 Go to Project > Add Windows Form> Module>Add
Step 2Write the following code in module

Module Module1
    Sub main()
        Console.WriteLine("Wel-Come To MLC ")
        Console.ReadKey()
  End Sub
End Module

To Run the code
go to> Project > Windows Application Property > Application Type >Console Application >Start up object > Module name

Program 25 Sum of two numbers by Module

Module Module1
    Sub main()
        Dim a, b, c As Integer
        Console.WriteLine("Enter any two numbers ")
        a = Console.ReadLine()
        b = Console.ReadLine
        c = a + b
        Console.WriteLine("Sum={0}", c)
        Console.ReadKey()
  End Sub
End Module


Program 26 Multiple Document Interface

MDI - Multiple Document Interface application that allow users to work with multiple documents by opening more than one documents at a time. where as a Single Document Interface (SDI) application can manipulate one document at a time.
The MDI application acts as the parent and child relationship in a form. A parent form is a container that contains child forms, while child forms can be multiple to display different modules in a parent form.
Create three Form , Form1 Form2 and Form3
Form1
Coding for Form1
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        IsMdiContainer = True
        Me.Text = "MLC "
        PictureBox1.Image = Image.FromFile("C:\Users\Dell\Pictures\Camera Roll\mlccollege.gif")
        PictureBox1.Height = 550
        PictureBox1.Width = 750
    End Sub

Coding for feed back Menu
    Private Sub FeedBackFormToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FeedBackFormToolStripMenuItem.Click
        PictureBox1.Visible = False
        Dim frm2 As New Form2
        frm2.MdiParent = Me
        frm2.Show()
    End Sub

Coding for VB.Net Menu
    Private Sub VBNetToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VBNetToolStripMenuItem.Click
        PictureBox1.Visible = False
        Dim frm3 As New Form3
        frm3.MdiParent = Me
        frm3.Show()
    End Sub
End Class

Coding for Form 2 Load
Public Class Form2

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = "MLC Korba"
        label1.text = "Fill the Feedback Form"
        Button1.Text = "Submit"
        Button1.BackColor = Color.SkyBlue
        Button2.Text = "Cancel"
        Button2.BackColor = Color.Red
    End Sub

Coding for Button2
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Dispose()
    End Sub

Coding for Button1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        MsgBox("Susseccfully Form Submitted ")
    End Sub
End Class


Coding for Form3 Load

Public Class Form3
    Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = "MLC Korba"
        Label1.Text = "Wel-Come to MLC "
        Label1.BackColor = Color.Green
        Label2.Text = "VB.Net"
        Label2.BackColor = Color.SkyBlue
    End Sub

End Class

Program 27 Listview 

Coding for Form Load
Public Class Form4

    Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = "MLC Korba"
        ListView1.View = View.Details
        ListView1.GridLines = True
        Label1.Text = "Enter the Roll No."
        Label2.Text = "Enter Your Name"
        Label3.Text = "Enter Your Email"
        Label4.Text = "Enter Course"
        Label5.Text = "Students Details"
        ListView1.Columns.Add("Roll No", 70, HorizontalAlignment.Left)
        ListView1.Columns.Add("Name", 100, HorizontalAlignment.Left)
        ListView1.Columns.Add("Email", 150, HorizontalAlignment.Left)
        ListView1.Columns.Add("Course", 100, HorizontalAlignment.Left)
        ListView1.BackColor = Color.LightSkyBlue
        Button1.Text = "Add New Entry"
        Button1.ForeColor = Color.White
        Button1.BackColor = Color.Green
        Label5.ForeColor = Color.Red
        Button2.Text = "Exit"
        Button2.BackColor = Color.Red
        Button3.Text = "Clear"
        Button3.BackColor = Color.Chocolate
    End Sub

   Coding for Button 1 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim str(4) As String
        Dim itm As ListViewItem
        str(0) = TextBox1.Text
        str(1) = TextBox2.Text
        str(2) = TextBox3.Text
        str(3) = TextBox4.Text
        itm = New ListViewItem(str)
        ListView1.Items.Add(itm)
    End Sub

Coding for Button 2    
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        End
    End Sub

Coding for Button 3
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
    End Sub
End Class

Program 28 Progress Bar

Coding for Button 1
Public Class Form5

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ProgressBar1.Visible = True
        Dim i As Integer
        ProgressBar1.Minimum = 0
        ProgressBar1.Maximum = 300
        For i = 0 To 300 Step 1
            ProgressBar1.Value = i
            If i > ProgressBar1.Maximum Then
                i = ProgressBar1.Maximum

            End If
        Next
        MsgBox("Successfully Completed")
    End Sub

Coding for Form Load
    Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = "MLC Korba"
        Button1.Text = "Show"
        Label1.Text = "Click to display the Progress status of the progress Bar"
        Label1.ForeColor = Color.Green
        ProgressBar1.Visible = False
        Dim probar2 As ProgressBar = New ProgressBar
        probar2.Location = New Point(80, 90)
        probar2.Minimum = 0
        probar2.Maximum = 500
        probar2.Value = 470
        Me.Controls.Add(probar2)

    End Sub

End Class

Prgram 29 Font Style Bold Italic Underline and change the fore color and back color of the text


Coding for Checkbox 1
Public Class Form6

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        If CheckBox1.Checked Then
            TextBox1.Font = New Font(TextBox1.Font, TextBox1.Font.Style Or FontStyle.Bold)
        Else
            TextBox1.Font = New Font(TextBox1.Font, TextBox1.Font.Style And Not FontStyle.Bold)
        End If

    End Sub

Coding for Checkbox 2   
    Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
        If CheckBox2.Checked Then
            TextBox1.Font = New Font(TextBox1.Font, TextBox1.Font.Style Or FontStyle.Italic)
        Else
            TextBox1.Font = New Font(TextBox1.Font, TextBox1.Font.Style And Not FontStyle.Italic)
        End If

    End Sub

Coding for Checkbox 3
    Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
        If CheckBox3.Checked Then
            TextBox1.Font = New Font(TextBox1.Font, TextBox1.Font.Underline Or FontStyle.Underline)
        Else
            TextBox1.Font = New Font(TextBox1.Font, TextBox1.Font.Style And Not FontStyle.Underline)
        End If
    End Sub

Coding for Radiobutton 1
     Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        TextBox1.ForeColor = Color.Red
        TextBox1.Font = New Font("Arial", 18)
    End Sub

Coding for Radiobutton 2 
    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        TextBox1.ForeColor = Color.Green
        TextBox1.Font = New Font("Arial", 18)
    End Sub

Coding for Radiobutton 3
    Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
        TextBox1.BackColor = Color.Yellow
        TextBox1.Font = New Font("Arial", 18)
    End Sub

Coding for Radiobutton 4
    Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
        TextBox1.BackColor = Color.Blue
        TextBox1.Font = New Font("Arial", 18)
    End Sub
 End Class

Program 30 Web browser Tool


Coding for Button 1
Public Class Form7

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        WebBrowser1.Navigate(TextBox1.Text)
    End Sub
End Class
===============================================================
Program 31 User Define Function in Module with Procedure
Sum of two numbers 
Here Function name is add with two arguments num1 and num2

Module Module1
    Sub add(ByVal num1 As Integer, ByVal num2 As Integer)
        Dim ans As Integer
        ans = num1 + num2
        Console.WriteLine(ans)
    End Sub
    Sub main()
        Dim a, b As Integer
        Console.WriteLine("Enter the value of a ")
        a = Console.ReadLine()
        Console.WriteLine("Enter the value of b ")
        b = Console.ReadLine
        add(a, b)
        Console.ReadKey()
    End Sub
End Module
========================================================
Program 32 User Define Function in Module with Procedure 
Calculator Program 

Module Module1
   Sub add(ByVal num1 As Integer, ByVal num2 As Integer)
        Dim ans As Integer
        ans = num1 + num2
        Console.Write("Sum ")
        Console.WriteLine(ans)
    End Sub

    Sub minus(ByVal num1 As Integer, ByVal num2 As Integer)
        Dim ans As Integer
        ans = num1 - num2
        Console.Write("Subtraction ")
        Console.WriteLine(ans)
    End Sub

    Sub multi(ByVal num1 As Integer, ByVal num2 As Integer)
        Dim ans As Integer
        ans = num1 * num2
        Console.Write("Multiplication ")
        Console.WriteLine(ans)
    End Sub
    Sub div(ByVal num1 As Integer, ByVal num2 As Integer)
        Dim ans As Integer
        ans = num1 / num2
        Console.Write("Divide ")
        Console.WriteLine(ans)
    End Sub

    Sub main()
        Dim a, b As Integer
        Console.WriteLine("Enter the value of a ")
        a = Console.ReadLine()
        Console.WriteLine("Enter the value of b ")
        b = Console.ReadLine
        add(a, b)
        minus(a, b)
        multi(a, b)
        div(a, b)
        Console.ReadKey()
    End Sub
End Module
==============================================================
Program 32 User Define Function in Module with Function
Greatest among two numbers

Module Module2
    Function great(ByVal a As Integer, ByVal b As Integer) As Integer
        If a > b Then
            Console.Write("A is greater ")
            Return a
        Else
            Console.Write("B is greater ")
            Return b
        End If
    End Function
        Sub main()
        Dim a, b, ans As Integer
        Console.WriteLine("Enter the value of A ")
        a = Console.ReadLine
        Console.WriteLine("Enter the value of B ")
        b = Console.ReadLine
        ans = great(a, b)
        Console.Write(ans)
        Console.ReadKey()
    End Sub
End Module
Output of the Program

================================================================
Program 33 Context Menu Strip Tool




Add context menu strip and rich text box tool in your Form
Change the Property of rich text box to 
Contextmenustrip- Contextmenustrip1
Dock-Fill
Enable - True
Public Class Form8

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

    Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem.Click
        RichTextBox1.Copy()
    End Sub

    Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteToolStripMenuItem.Click
        RichTextBox1.Paste()
    End Sub
End Class

Run the Program and Type text in Rich text box area
Wel-Come to MLC
select the text and right click over the text you have three option Cut Copy Paste and you can perform the operation
Output of Program




































    

 




















  



 

Visual Basic .Net Programming

 Program 1 Sum of Two Numbers Form Design for Sum of Two Numbers Coding for OK Button Dim a, b, c as integer a=textbox1.text b=textbox2.text...