Chikita leaderboard

Martes, Nobyembre 8, 2011

How to use ListBox and Do-While Loop Statement in VB 6.0

ListBox is a powerful control in MS Visual Basic 6.0.  It has wide range of properties that can be helpful in creating data rich programs. For example, you set the Sorted attribute to True to create ListBox controls that automatically sort their items in alphabetical order. By acting on the Columns property, you create a different type of list box, with several columns and a horizontal scroll bar, instead of the default list box with a single column and a vertical scroll bar along its right border. You can make assignments for both these properties only at design time, and you can't change the style of the ListBox control while the program is running.

In this video tutorial, you will learn how to use some of the properties of ListBox like ListCount, ListItem, List.Additem and so much more.  Here are the following code in this video tutorial:

Private Sub Command1_Click()
If List1.ListCount > 0 Then
List2.AddItem List1.Text
List1.RemoveItem List1.ListIndex
End If
End Sub

Private Sub Command2_Click()
Do While List1.ListCount > 0
List2.AddItem List1.List(0)
List1.RemoveItem 0
Loop
End Sub

Private Sub Command3_Click()
If List2.ListCount > 0 Then
List1.AddItem List2.Text
List2.RemoveItem List2.ListIndex
End If
End Sub

Private Sub Command4_Click()
Do While List2.ListCount > 0
List1.AddItem List2.List(0)
List2.RemoveItem 0
Loop

End Sub

Private Sub Form_Load()
List1.AddItem "Monday"
List1.AddItem "Tuesday"
List1.AddItem "Wednesday"
List1.AddItem "Thursday"
List1.AddItem "Friday"
List1.AddItem "Saturday"
List1.AddItem "Sunday"
End Sub

Share and Enjoy!

Walang komento:

Mag-post ng isang Komento