Thursday, 14 May 2015

Learn V B 6.0- ListBox Control -Add,Delete and Clear items from List

Learn Visual Basic 6.0- Working with ListBox Control -Add,Delete and Clear items from List.

Listbox is used to present a list of choices to the user.

This tutorial is focused on following points.

*How can you add list box control onto the form.

*How can you set the properties and write code  for adding items into  List .also remove and clear the items from the list.

*We can also include the functionality to enable the add button when we starts typing in the textbox.,disable the button,when No typing.

*Also at last ,we can change the look and feel of the form .so that it looks good and interactive..



Source code is available at link.

https://www.mediafire.com/?t0gye79hdgpmk8b



Please comment and Share :-)





Source Code:
'For adding items into the list
Private Sub add_Click()
List1.AddItem Text1.Text
Text1.Text = ""
Text1.SetFocus
lblcount.Caption = List1.ListCount
End Sub

'For clear items into the list
Private Sub clear_Click()
List1.clear
lblcount.Caption = List1.ListCount
End Sub

'For deleting items into the list
Private Sub del_Click()
Dim ind As Integer
ind = List1.ListIndex
If ind >= 0 Then
List1.RemoveItem ind
lblcount.Caption = List1.ListCount
End If

End Sub
'For enble and diable the command button
Private Sub Text1_Change()
add.Enabled = (Len(Text1.Text) > 0)
End Sub




Please comment and Share :-)