Ver Mensaje Individual
  #2 (permalink)  
Antiguo 21/08/2011, 02:33
Avatar de thegodinez
thegodinez
 
Fecha de Ingreso: octubre-2010
Ubicación: Culiacán, Sinaloa
Mensajes: 54
Antigüedad: 13 años, 6 meses
Puntos: 5
Respuesta: Visual Basic 2005: Cargar Combobox con textbox

Objetos necesarios
  1. ComboBox
  2. TextBox Multilinea
  3. Boton Agregar
  4. Boton Limpiar

Código:
    Private Sub BotonAgregar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BotonAgregar.Click
        'Se definen 3 variables
        Dim Enters, Repetir As Integer
        Dim Texto As String
        Dim Convertidor As String
        'Se asignan valores por default
        Repetir = 0
        Enters = 0
        Convertidor = ""
        'Se iguala el textbox a una variable
        Texto = TextBox.Text
        For X = 0 To Len(Texto) - 1
            If Texto(X) = Chr(13) Or X = Len(Texto) - 1 Then
                If X = Len(Texto) - 1 Then
                    Convertidor = Convertidor + Texto(X)
                    If ComboBox.FindString(Convertidor) <> -1 Then
                        Repetir = 1
                    End If
                    ComboBox.Items.Add(Convertidor)
                    Convertidor = ""
                Else
                    If ComboBox.FindString(Convertidor) <> -1 Then
                        Repetir = 1
                    End If
                    ComboBox.Items.Add(Convertidor)
                    Enters = Enters + 1
                    Convertidor = ""
                End If
            Else
                Convertidor = Convertidor + Texto(X)
            End If
        Next
        If Repetir = 1 Then
            MessageBox.Show("Error ha introducido un valor duplicado")
            ComboBox.Items.Clear()
        Else
            MessageBox.Show("Se han agregado los datos")
        End If
        Repetir = 0
    End Sub

    Private Sub BotonLimpiar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ComboBox.Items.Clear()
        TextBox.Clear()
    End Sub
funciona perfectamente lo elabore en visual basic 2010
jeje lo he agarrado como tarea, me ha salido :O , saludos desde CULIACÁN, SINALOA, MÉXICO...