Formación en Valor: Esperanza.
Núcleo Integrador: ListBox.
Objetivo: Programar listas.
ListBox: Este objeto nos permite mostrar una lista de opciones
Ejercicio Diseña el siguiente formulario:
CLIC SOBRE LA IMAGEN PARA VERLA MEJOR.
Copia el siguiente código y muestra el resultado con F5.
Dim x As Integer
Private Sub Command1_Click()
If List1.ListIndex = -1 Then
MsgBox "Seleccione el elemento", vbInformation, "ListBox"
Else
List2.AddItem List1.Text
List1.RemoveItem List1.ListIndex
End If
End Sub
Private Sub Command2_Click()
If List1.ListIndex = -1 Then
MsgBox "Seleccione el elemento", vbInformation, "ListBox"
Else
For x = 0 To List1.ListCount
List2.AddItem List1.List(x)
Next x
List1.Clear
End If
End Sub
Private Sub Command3_Click()
If List2.ListIndex = -1 Then
MsgBox "Seleccione el elemento", vbInformation, "ListBox"
Else
List1.AddItem List2.Text
List2.RemoveItem List2.ListIndex
End If
End Sub
Private Sub Command4_Click()
If List2.ListIndex = -1 Then
MsgBox "Seleccione el elemento", vbInformation, "ListBox"
Else
For x = 0 To List2.ListCount
List1.AddItem List2.List(x)
Next x
List2.Clear
End If
End Sub
Private Sub Form_Load()
List1.AddItem "ELEMENTO 1"
List1.AddItem "ELEMENTO 2"
List1.AddItem "ELEMENTO 3"
List1.AddItem "ELEMENTO 4"
End Sub
Teniendo en cuenta el Taller desarrollado en la clase pasada del COMBOBOX, desarrolle un programa similar utilizando LISTBOX, pero en este caso adicione un objeto IMAGE el cual debe cambiar al dar clic sobre el elemento de la lista dos.

No hay comentarios:
Publicar un comentario