Sunteți pe pagina 1din 3

USO DEL LISTBOX CUADRO DE LISTA

CONTENEDOR DE ELEMENTOS(ITEMS)
1.-Disear el interfaz elaborado por el profesor y dar los nombres respectivos a cada
objeto(control) en su propiedad Name.
2.- Codificar en cada boton y evento respectivo

3.- Ingresar elementos(nombres de personas) por teclado en la caja de texto para luego
agregarlos hacia el control listBox1 pulsando click en el Boton AGREGAR
4.- Luego Seleccionar cualquier elemento(nombre) de la lista1(ListBox1) y pasarlo hacia la
lista2(ListBox2) mediante el boton LISTA1 A LISTA2 , tal como se muestra en la sgte figura:

5.- Codificar para los dems botones: LISTA2 A LISTA1, EliminarUNO, BorrarTodo

Public Class LISTAS


Private Sub btnagregar_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnagregar.Click
Dim nombre As String
nombre = (TextBox1.Text)
ListBox1.Items.Add(nombre)
TextBox1.Text = ""
TextBox1.Focus()
End Sub
Private Sub BTNLISTA1ALISTA2_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles BTNLISTA1ALISTA2.Click
If (ListBox1.SelectedIndex <> -1) Then
ListBox2.Items.Add(ListBox1.SelectedItem)
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
End If
End Sub
Private Sub btneliminar_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles BTNELIMINAR.Click
If (ListBox1.SelectedIndex <> -1) Then
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
Else
ListBox2.Items.RemoveAt(ListBox2.SelectedIndex)
End If
End Sub
Private Sub BTNLISTA2ALISTA1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles BTNLISTA21LISTA1.Click
If (ListBox2.SelectedIndex <> -1) Then
ListBox1.Items.Add(ListBox2.SelectedItem)
ListBox2.Items.RemoveAt(ListBox2.SelectedIndex)
End If
End Sub
Private Sub BTNBORRARTODO_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles BTNBORRARTODO.Click
ListBox1.Items.Clear()
ListBox2.Items.Clear()
End Sub
End Class
RECORDAR:
-

Para seleccionar un elemento de la lista utilizamos la propiedad


SelectedItem
Para seleccionar un elemento de la lista a partir de su base
indice 0 utilizamos la propiedad SelectedIndex
El operador <> nos indica diferente
Count obtiene el numero total de elementos de una lista a partir
de su indice,es decir: totalElemntos=ListBOx1.Items.Count -1

USO DEL COMBOBOX

Private Sub cboproducto_SelectedIndexChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
cboproducto.SelectedIndexChanged
Dim indice As Integer
indice = cboproducto.SelectedIndex
Select Case (indice)
Case 0
Me.txtprecio.Text = "5.00"
Case 1
Me.txtprecio.Text = "7.00"
Case 2
Me.txtprecio.Text = "10.00"
End Select
End Sub
SOLO CUANDO HAGA CLICK EN CALCULAR MOSTRARA EL SUBTOTAL Y TOTAl al
mismo tiempo
Private Sub btncalcular_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btncalcular.Click
Dim cantidad, subto, igv, total, precio As Double
cantidad = Val(txtcant.Text)
precio = Val(txtprecio.Text)
subto = cantidad * precio
total=subto
txtsubto.Text = subto.ToString()
txttotal.Text = total.ToString()
End Sub
CALCULE UD POR CODIGO EN EL CHECKBOX(CHKIGV)CUANDO HAGA CLIK Y LO
ACTIVE DEBE MOSTRAR EL IGV Y EL TOTAL TANBIEN VARIA(VER FIGURA)

S-ar putea să vă placă și