VK LABELS

Sunday, 16 March 2014

Demonstrate the Events: Mouse Click, Mouse Down, Key Down, Form Load

DEMONSTRATE THE FOLLOWING EVENTS: MOUSE CLICK, MOUSE DOWN, KEY DOWN, FORM LOAD

Public Class Form1
    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        Label1.ForeColor = Color.Green
        Label1.Text = "Key Down"
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Label1.Text = "Form Load"
    End Sub

    Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
        Label1.ForeColor = Color.Red
        Label1.Text = "Mouse Click"
    End Sub

    Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
        Label1.ForeColor = Color.Blue
        Label1.Text = "Mouse Down"
    End Sub

End Class


Handle Devide by Zero Exception in VB.Net Console Applications

HANDLE DEVIDE BY ZERO EXCEPTION:
  • Type this program in Visual Basic Console Application.


Module Module1
    Sub division(ByVal num1 As Integer, ByVal num2 As Integer)
        Dim result As Long
        Try
            result = num1 \ num2
        Catch e As DivideByZeroException
            Console.WriteLine("Exception caught: {0}", e)
        Finally
            Console.WriteLine("Result: {0}", result)
        End Try
    End Sub
    Sub Main()
        Dim a, b As Long
        Console.WriteLine("Division Program")
        Console.WriteLine("Type First Value:")
        a = Console.ReadLine
        Console.WriteLine("Type Second Values:")
        b = Console.ReadLine
        division(a, b)
        Console.ReadKey()
    End Sub

End Module

Display Hierarchical Representations of Items with Tree view control using Program:

DISPLAY HIERARCHICAL REPRESENTATIONS OF ITEMS WITH TREE VIEW CONTROL USING PROGRAM:

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim TreeView1 As TreeView
        TreeView1 = New TreeView()
        TreeView1.Location = New Point(10, 10)
        TreeView1.Size = New Size(250, 250)
        Me.Controls.Add(TreeView1)
        TreeView1.Nodes.Clear()
        Dim root As TreeNode
        root = New TreeNode("Applications")
        TreeView1.Nodes.Add(root)
        TreeView1.Nodes(0).Nodes.Add(New TreeNode("Project 1"))
        For loopindex As Integer = 1 To 5
            TreeView1.Nodes(0).Nodes(0).Nodes.Add(New  _
                TreeNode("Sub Project 1." & Str(loopindex)))
        Next loopindex
        TreeView1.Nodes(0).Nodes.Add(New TreeNode("Project 2"))
        For loopindex As Integer = 1 To 6
            TreeView1.Nodes(0).Nodes(1).Nodes.Add(New  _
                TreeNode("Sub Project 2." & Str(loopindex)))
        Next loopindex
        Me.Text = "Display hierarchical representations of items"
    End Sub
End Class


Add String to Combo Box and List Box Using VB.Net

ADD STRING TO COMBO BOX AND LIST BOX:

ADD STRINGS FROM TEXTBOX:

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ComboBox1.Items.Add(TextBox1.Text)
    End Sub

ADD STRINGS TO COMBO BOX USING PROGRAM:

  Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ComboBox1.Items.Clear()
        ComboBox1.Items.Add("ONE")
        ComboBox1.Items.Add("TWO")
        ComboBox1.Items.Add("THREE")
        ComboBox1.Items.Add("FOUR")
        ComboBox1.Items.Add("FIVE")
        ComboBox1.Text = "Select"
    End Sub

ADD STRINGS TO LISTBOX FROM COMBO BOX:

 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ListBox1.Items.Add(ComboBox1.SelectedItem)
    End Sub

CLEAR COMBO BOX:

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

CLEAR LIST BOX:

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

SORT COMBO BOX:

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        ComboBox1.Sorted = True
    End Sub


Connect Visual Studio and Oracle Database

Connect Visual Studio and Oracle Database:

  • Install Visual studio and Oracle database.
  • Download and install ODAC (Oracle Data Access Components) for Windows.
  • Open visual studio.
  • Click Tools>>Connect to Database.
  • Select Data Source to Oracle Database.
  • Select Data Source Name (XE for Express Edition of Oracle).
  • Click Test Connect and ok.