Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

PRACTICAL-4

Aim: Write a program in VB that transfers selected items from listbox 1 to listbox2
and viceversa

Theory/Logic: The items are added in listbox during designtime.Two command buttons are
used to transfer selected items forom one to onother listbox.The selected item is transferred form
left to right on clicking >> butoon.The reverse procedure is done through << button.If nothing is
selected and any button is pressed then usedefined error is dispayed to select item.

The controls which are used in project are listed below with respective properties.

Object Properties Value


Label1 Name lblHeader
Caption project-1- LISTBOX
Font Size 14
Listbox 1 Name List1
Multiselect 0 –None
Listbox 2 Name List2
Multiselect 0 –None
CommandButton1 Name Command1
Caption >>
Tool tip text Move Right
CommandButton2 Name Command2
Caption <<
Tool tip text Move Left
Program Code:

Private Sub Command1_Click()

If (List1.ListIndex < 0) Then

MsgBox "select item"

Else

List2.AddItem List1.List(List1.ListIndex)

List1.RemoveItem List1.ListIndex

End If

End Sub

Private Sub Command2_Click()

If (List2.ListIndex < 0) Then

MsgBox "select item"

Else

List1.AddItem List2.List(List2.ListIndex)

List2.RemoveItem List2.ListIndex

End If

End Sub

Output:

You might also like