No permitr datos Repetidos en un Listbox
Hola , estoy buscado la manera de impedir el ingreso de datos reptidos a un Listbox se me hace dificil, no c si alguien sabe como hacerlo.
Saludoz
Lainuxxx
Saludoz
Lainuxxx
hola, podrias hacer una comprobacion antes de agregar el elemento para ver si ya existe. si no existe lo agregas
utiliza un ciclo for con los elementos del listbox y ve comprobando cada elemento con el valor que quieres ingresar
espero te sirva de algo el mensaje.
utiliza un ciclo for con los elementos del listbox y ve comprobando cada elemento con el valor que quieres ingresar
espero te sirva de algo el mensaje.
que tal, en realidad eso es muy simple, nada dificil, abre un nuevo proyecto de vb, agregale tres objetos, un text box, un comandbutton y un listview, no les cambies el nombre y pega dentro del formulario este codigo, debe funcionar, ya lo probe.
suerte, bye
Public Function CCargaProdEnc()
'Aspecto de listview
With Me.ListView1
.View = lvwReport
.GridLines = True
.FullRowSelect = True
.LabelEdit = lvwManual
.ColumnHeaders.Add , , "Productos", 2400
End With
End Function
Private Sub Command1_Click()
Dim lsarticulo As String
lsarticulo = Trim(Me.Text1.Text)
If lsarticulo = "" Then
MsgBox "El campo no puede estar vacío..."
Exit Sub
End If
Set itmFound = Me.ListView1.FindItem(lsarticulo)
If itmFound Is Nothing Then
Set items = Me.ListView1.ListItems.Add(, , lsarticulo)
Else
MsgBox "El producto ya está en la lista."
End If
End Sub
Private Sub Form_Load()
Move (Screen.Width - Width) 2, (Screen.Height - Height) 2
Me.CCargaProdEnc
End Sub
suerte, bye
Public Function CCargaProdEnc()
'Aspecto de listview
With Me.ListView1
.View = lvwReport
.GridLines = True
.FullRowSelect = True
.LabelEdit = lvwManual
.ColumnHeaders.Add , , "Productos", 2400
End With
End Function
Private Sub Command1_Click()
Dim lsarticulo As String
lsarticulo = Trim(Me.Text1.Text)
If lsarticulo = "" Then
MsgBox "El campo no puede estar vacío..."
Exit Sub
End If
Set itmFound = Me.ListView1.FindItem(lsarticulo)
If itmFound Is Nothing Then
Set items = Me.ListView1.ListItems.Add(, , lsarticulo)
Else
MsgBox "El producto ya está en la lista."
End If
End Sub
Private Sub Form_Load()
Move (Screen.Width - Width) 2, (Screen.Height - Height) 2
Me.CCargaProdEnc
End Sub