Visual Basic - COMBOBOX "AUTOMATICO"

Life is soft - evento anual de software empresarial
 
Vista:

COMBOBOX "AUTOMATICO"

Publicado por Crash (14 intervenciones) el 06/10/2003 05:44:33
hola.. espero que me puedan ayudar, mi idea es esta : tengo un Text1 y Un ComboBox; Suponiendo que en el Combo tubiera una lista de Datos, quisiera que al ir escribiendo una letra en el Text se fuera actualizando el ComboBox, ( asi como cuando consultamos la Ayuda de Visual Basic, en el Indice, que conforme vamos escribiendo para formar una palabra, en la parte de abajo se va actualizando conforme va coincidiendo.... Gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:COMBOBOX

Publicado por Victor Collado (51 intervenciones) el 06/10/2003 23:13:35
Hola

Te pongo un ejemplo, en este ejemplo tengo un combobox ( combo1)
y un TextBox ( Text1) en el evento change del Textbox escribes lo siguiente:

Private Sub Text1_Change()
Dim strText As String
Dim i As Integer
Dim intL As Integer
Dim x As Integer

strText = UCase(Me.Text1.Text)
intL = Len(strText)

For i = 0 To Me.Combo1.ListCount - 1
If InStr(1, Mid(UCase(Me.Combo1.List(i)), 1, intL), strText) Then
Me.Combo1.ListIndex = i
End If
Next

End Sub

Con este ejemplo vamos a seleccionar cualquier coincidencia en el combobox comenzando desde el principio de cada palabra en el combobox, es decir contando desde la primera letra.

Saludos

Victor Collado
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:COMBOBOX

Publicado por Victor Collado (51 intervenciones) el 06/10/2003 23:18:53
Hola

Se me olvido selecionarte el texto debes poner esto:

Private Sub Text1_Change()
Dim strText As String
Dim i As Integer
Dim intL As Integer
Dim x As Integer

strText = UCase(Me.Text1.Text)
intL = Len(strText)
x = 0

For i = 0 To Me.Combo1.ListCount - 1
If InStr(1, Mid(UCase(Me.Combo1.List(i)), 1, intL), strText) Then
Me.Combo1.ListIndex = i
Me.Combo1.SelStart = 0
Me.Combo1.SelLength = Len(Me.Combo1.List(i))
x = x + 1
End If
Next

End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Si Funciono

Publicado por Crash (14 intervenciones) el 06/10/2003 23:52:41
Gracias de nuevo Victor
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

GRACIAS

Publicado por Crash (14 intervenciones) el 06/10/2003 23:49:36
lo voy a probar en este momento.... una pregunta... que significa o que funcion tiene "ME" ??
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:GRACIAS

Publicado por Victor Collado (51 intervenciones) el 07/10/2003 00:17:59
Hola

Me alegro que te funciono, la palabra Me en este caso se refiere a el form en si, si estas dentro de una clase, Me es la clase y dentro estaran las propiedades , Methods de la clase, etc.

Saludos

Victor Collado
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

UnA VaRiAnTe A eSte CoDiGo...

Publicado por Nocturno (11 intervenciones) el 07/10/2003 00:20:30
PRESISAMENTE IBA A PREGUNTAR ALGO PARECIDO....SOLO QUE YO QUERIA SABER COMO PROGRAMAR LA BUSQUEDA MEDIANTE EL COMBO ( SIN EL CUADRO DE TEXTO ), QUE AL ESCRIBIR EN EL COMBO SE VAYA SELECCIONANDO LO QUE VA COINCIDIENDO, COPIE EL CODIGO QUE LE DISTE A CRASH ( CAMBIANDO ME.TEXT POR ME.COMBO CLARO ) PERO NO ME FUNCIONO... QUE FALLO ?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:UnA VaRiAnTe A eSte CoDiGo...

Publicado por Victor Collado (51 intervenciones) el 07/10/2003 17:59:37
Hola

No solo debes cambiar "ME.TEXT POR ME.COMBO" sino que debes ponerlo en evento Change del combobox asi:

Private Sub Combo1_Change()
Dim strText As String
Dim i As Integer
Dim intL As Integer
Dim x As Integer

strText = UCase(Me.Combo1.Text)

intL = Len(strText)
x = 0

For i = 0 To Me.Combo1.ListCount - 1
If InStr(1, Mid(UCase(Me.Combo1.List(i)), 1, intL), strText) Then
Me.Combo1.ListIndex = i
Me.Combo1.SelStart = 0
Me.Combo1.SelLength = Len(Me.Combo1.List(i))
End If
Next
End Sub

saludos
Victor Collado
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

No Me funciono...

Publicado por Nocturno (11 intervenciones) el 07/10/2003 23:51:24
SI LO TENIA CON EL EVENTO CHANGE, CON LOS MISMOS NOMBRES Y FUNCIONA PARCIALMENTE, MIRA TE EXPLICO: SI EN LA LISTA DEL COMBO TENGO ENERO, FEBRERO , MARZO, ABRIL. MAYO..... SI ESCRIBO "F" ME APARECE FEBRERO( HASTA AHI VA BIEN ) PERO SI SIGO ESCRIBIENDO "FE", ME SELECCIONA ENERO, LO QUE VEO, ES QUE LA LETRA QUE VOY ESCRIBIENDO, LA COMPARA CON LA PRIMERA LETRA QUE TENGA ALGUN ELEMENTO DEL COMBO.... QUE CREES QUE SEA?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:No Me funciono...

Publicado por Jorge (67 intervenciones) el 08/10/2003 00:09:27
Hola declara esto primero en declaraciones
Option Explicit
Private Const CB_FINDSTRING = &H14C
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long

luego en el evento change del combo pon esto
Dim iStart As Integer
Dim sString As String
Static iLeftOff As Integer

iStart = 1
iStart = txtciudad.SelStart

If iLeftOff <> 0 Then
txtciudad.SelStart = iLeftOff
iStart = iLeftOff
End If

sString = CStr(Left(txtciudad.Text, iStart))
txtciudad.ListIndex = SendMessage(txtciudad.hwnd, _
CB_FINDSTRING, -1, ByVal CStr(Left( _
txtciudad.Text, iStart)))

If txtciudad.ListIndex = -1 Then
If txtcomuna = "" Then en esta parte lo puse asi porque me causaba conflicto al llenar el combo desde la base de dastos
iLeftOff = Len(sString)
txtciudad.Text = sString
End If
espero te sirva
Chao
End If
txtciudad.SelStart = iStart

iLeftOff = 0
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar