Monday, 6 February 2012

Using a Combo Box and a List Control

The following program demonstrates a combo box and a list control. The combo box is populated with items and is toggled with the list control with its given items.
Option Explicit
Dim i As Integer
Dim j As Integer
Dim arr() As String
Dim jrr() As String
Dim krr() As String
Private Sub Command1_Click()
'Combo1.RemoveItem (1)
'Combo1.RemoveItem (2)
'Combo1.RemoveItem (3)
Combo1.Clear
Combo1.Refresh
Combo1.AddItem "Shoes"
Combo1.AddItem "Tie"
Combo1.AddItem "Shirt"
i = Combo1.ListCount
ReDim jrr(i)
For i = 0 To Combo1.ListCount
jrr(i) = Combo1.List(i)
Next
List1.Clear
For i = 0 To Combo1.ListCount
List1.AddItem Combo1.List(i)
Next
End Sub
Private Sub Command2_Click()
If j = 0 Then
krr = arr
j = 1
Else
krr = jrr
j = 0
End If
List1.Clear
For i = 0 To Combo1.ListCount
List1.AddItem krr(i)
Next
End Sub
Private Sub Form_Load()
j = 0
Combo1.Clear
Combo1.Refresh
Combo1.AddItem "Mango"
Combo1.AddItem "Orange"
Combo1.AddItem "Custard Apple"
i = Combo1.ListCount
ReDim arr(i)
For i = 0 To Combo1.ListCount
arr(i) = Combo1.List(i)
Next
For i = 0 To Combo1.ListCount
List1.AddItem Combo1.List(i)
Next
End Sub

No comments:

Post a Comment