Ver Mensaje Individual
  #2 (permalink)  
Antiguo 30/09/2010, 14:01
Ka0stj
 
Fecha de Ingreso: febrero-2010
Ubicación: México
Mensajes: 738
Antigüedad: 14 años, 2 meses
Puntos: 37
Respuesta: recorrer listas en vb

Hola marinella

Puedes hacerlo de la siguientes formas:

Mediante el FindStringExact

Código vb:
Ver original
  1. Dim valor As Integer = 0
  2.  
  3.         valor = Me.ListBox1.FindStringExact(Me.TextBox1.Text)
  4.  
  5.         If valor <> ListBox.NoMatches Then
  6.             ListBox1.SetSelected(valor, True)
  7.         Else
  8.             MsgBox("No existe.")
  9.         End If

Ó recorriendo toda la lista comparando los Items.

Código vb:
Ver original
  1. Dim bandera As Boolean = False
  2.  
  3.         For I As Integer = 0 To ListBox1.Items.Count - 1
  4.             If Me.ListBox1.Items(I) = "La cadena que buscaras" Then
  5.                 bandera = True
  6.                 Exit For
  7.             End If
  8.         Next
  9.  
  10.         If bandera = True Then
  11.             MsgBox("Si existe.")
  12.         Else
  13.             MsgBox("No existe.")
  14.         End If

Espero y te sirva, Saludos!