Write a programin VB.Net to display following form. Add button will add the text from textbox to list1.Button ' >' will move selected items from List1 to List2 , '>>' will move all items from List1 to List Button'<' will move selected item from List2 to List1, '<<' will move all items from List2 to List1.Clearbutton willclear both the List. While moving items fromList1 to List2 duplicates items are not allowded.


Public Class Form1

    Dim i, j As Integer

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


    End Sub


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


        For j = 0 To ListBox2.Items.Count - 1

            If (ListBox1.Items.Item(ListBox1.SelectedIndex)) = ListBox2.Items.Item(j) Then

                Exit For

            End If

        Next

        If j = ListBox2.Items.Count Then

            ListBox2.Items.Add(ListBox1.Items.Item(ListBox1.SelectedIndex))

            ListBox1.Items.Remove(ListBox1.SelectedItem)

        Else

            MsgBox("Element Is Already Added")

        End If


    End Sub


    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

        Application.Exit()

    End Sub


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

        ListBox1.Items.Add(TextBox1.Text)

        TextBox1.Text = ""

        TextBox1.Focus()

    End Sub


    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

        ListBox1.Items.Clear()

        ListBox2.Items.Clear()

    End Sub


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

        Try

            For i = 0 To ListBox1.Items.Count - 1

                For j = 0 To ListBox2.Items.Count - 1

                    If ListBox1.Items.Item(i) = ListBox2.Items.Item(j) Then

                        Exit For

                    End If

                Next

                If j = ListBox2.Items.Count Then

                    ListBox2.Items.Add(ListBox1.Items.Item(i))


                End If

            Next

            For i = 0 To ListBox1.Items.Count - 1

                ListBox1.Items.Remove(ListBox1.Items.Item(i))

            Next


        Catch ex As Exception

            ListBox1.Items.Remove(ListBox1.Items.Item(ListBox1.Items.Count - 1))

        End Try

    End Sub


    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        ListBox1.Items.Add(ListBox2.Items.Item(ListBox2.SelectedIndex))

        ListBox2.Items.Remove(ListBox2.SelectedItem)

    End Sub


    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click


        Try

            For i = 0 To ListBox2.Items.Count - 1

                ListBox1.Items.Add(ListBox2.Items.Item(i))


            Next

            For i = 0 To ListBox2.Items.Count - 1

                ListBox2.Items.Remove(ListBox2.Items.Item(i).ToString)

            Next i

        Catch ex As Exception

            ListBox2.Items.Remove(ListBox2.Items.Item(ListBox2.Items.Count - 1))

        End Try

       

    End Sub


    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged


    End Sub

End Class
Write a programin VB.Net to display following form. Add button will add the text from textbox to list1.Button ' >' will move selected items from List1 to List2 , '>>' will move all items from List1 to List Button'<' will move selected item from List2 to List1, '<<' will move all items from List2 to List1.Clearbutton willclear both the List. While moving items fromList1 to List2 duplicates items are not allowded. Write a programin VB.Net to display following form.   Add button will add the text from textbox to list1.Button ' >'  will move selected items from List1 to List2 , '>>' will move all items from List1 to List  Button'<' will move selected item from List2 to List1, '<<' will move all items from List2 to List1.Clearbutton willclear both the List. While moving items fromList1 to List2 duplicates items are not allowded. Reviewed by on April 27, 2015 Rating: 5
Powered by Blogger.