Foros del Web » Programación para mayores de 30 ;) » Programación General » Visual Basic clásico »

Duda para cargar image

Estas en el tema de Duda para cargar image en el foro de Visual Basic clásico en Foros del Web. Hola! tengo la siguiente instrucción : Private Sub Image1_Click() Image1.Picture = LoadPicture(Label20) End Sub pero quiero que cuando se ingrese una matricula automaticamente se carge ...
  #1 (permalink)  
Antiguo 18/05/2011, 22:07
Avatar de Shizuka  
Fecha de Ingreso: marzo-2011
Mensajes: 106
Antigüedad: 13 años
Puntos: 4
Duda para cargar image

Hola! tengo la siguiente instrucción :

Private Sub Image1_Click()
Image1.Picture = LoadPicture(Label20)
End Sub

pero quiero que cuando se ingrese una matricula automaticamente se carge el image con el path que contiene el Label, sin necesidad de hacer clic en el image
tienen idea de que puedo hacer?

(esta es la instrucción para buscar la matricula)
Adodc1.Recordset.MoveFirst
dato = InputBox("INGRESE LA MATRÍCULA A BUSCAR :", "BUSQUEDA")
If dato = "" Then
Exit Sub
End If
Adodc1.Recordset.Find ("matricula=" + "'" + dato + "'")
If Adodc1.Recordset.EOF Then
MsgBox "LA MATRÍCULA QUE INGRESO NO EXISTE, POR FAVOR INTENTELO DE NUEVO", 64, "AVISO"
Adodc1.Recordset.MoveFirst
Exit Sub
End If


Y otra duda, igual me pasa con los comboboxes, que puedo hacer para que al momento de hacer la consulta (con el código de arriba) me muestre los comboboxes y el image...aqui una captura:




gracias por la ayuda de antemano :3
__________________
Will you please tell me the way to the sky?

Última edición por Shizuka; 18/05/2011 a las 22:20
  #2 (permalink)  
Antiguo 19/05/2011, 07:09
Avatar de lokoman  
Fecha de Ingreso: septiembre-2009
Mensajes: 502
Antigüedad: 14 años, 6 meses
Puntos: 47
Respuesta: Duda para cargar image

Hola!!
Revisa el CODE y nos cuentas:

Código vb:
Ver original
  1. Adodc1.Recordset.MoveFirst
  2.     dato = InputBox("INGRESE LA MATRÍCULA A BUSCAR :", "BUSQUEDA")
  3.    
  4.     If dato = "" Then Exit Sub
  5.    
  6.     Adodc1.Recordset.Find ("matricula=" + "'" + dato + "'")
  7.     If Adodc1.Recordset.EOF Then
  8.         MsgBox "LA MATRÍCULA QUE INGRESO NO EXISTE, POR FAVOR INTENTELO DE NUEVO", 64, "AVISO"
  9.         Adodc1.Recordset.MoveFirst
  10.         Exit Sub
  11.     End If
  12.    
  13. 'CARGAR LA IMAGEN, YA QUE SE ENCONTRO EL REGISTRO
  14.    Image1.Picture = LoadPicture(Label20.Caption)
  15.  
  16. 'LOS COMBOS DEBEN ESTAR LLENOS
  17.    
  18. 'ASUMO QUE EL PRIMER ITEM DEL COMBO_GENERO ES "FEMENINO"
  19.    If UCase(Adodc1.Recordset("GENERO")) = "FEMENINO" Then COMBO_GENERO.ListIndex =0
  20.     If UCase(Adodc1.Recordset("GENERO")) = "MASCULINO" Then COMBO_GENERO.ListIndex =1
  21.    
  22. 'ASUMO QUE EL PRIMER ITEM DEL COMBO_NIVEL_ESCOLAR ES "PREESCOLAR"
  23.    If UCase(Adodc1.Recordset("NIVELE")) = "PREESCOLAR" Then COMBO_NIVEL_ESCOLAR.ListIndex =0
  24.     If UCase(Adodc1.Recordset("NIVELE")) = "BASICO" Then COMBO_NIVEL_ESCOLAR.ListIndex =1
  25.     If UCase(Adodc1.Recordset("NIVELE")) = "UNIVERSITARIO" Then COMBO_NIVEL_ESCOLAR.ListIndex =2
  #3 (permalink)  
Antiguo 19/05/2011, 08:34
Avatar de Shizuka  
Fecha de Ingreso: marzo-2011
Mensajes: 106
Antigüedad: 13 años
Puntos: 4
Respuesta: Duda para cargar image

Muchas gracias por responder...asi fue como quedó con el código



la imagen ya carga :) gracias *3* , pero siguen sin aparecer los datos del combo
__________________
Will you please tell me the way to the sky?
  #4 (permalink)  
Antiguo 19/05/2011, 08:52
Avatar de lokoman  
Fecha de Ingreso: septiembre-2009
Mensajes: 502
Antigüedad: 14 años, 6 meses
Puntos: 47
Respuesta: Duda para cargar image

Tienes los COMBOS enlazados con el ADO_CONTROL, o los llenas en el FORM_LOAD?

Si los llenas en el FORM_LOAD()
Código vb:
Ver original
  1. COMBO_GENERO.CLEAR
  2. COMBO_GENERO.ADDITEM "FEMENINO"
  3. COMBO_GENERO.ADDITEM "MASCULINO"
  4.  
  5. COMBO_NIVEL_ESCOLAR.CLEAR
  6. COMBO_NIVEL_ESCOLAR.ADDITEM "PREESCOLAR"
  7. COMBO_NIVEL_ESCOLAR.ADDITEM "BASICO"
  8. COMBO_NIVEL_ESCOLAR.ADDITEM "UNIVERSITARIO"

Entonces, en tu codigo:
Código vb:
Ver original
  1. 'LOS COMBOS DEBEN ESTAR LLENOS
  2.    
  3. 'ASUMO QUE EL PRIMER ITEM DEL COMBO_GENERO ES "FEMENINO"
  4.    If UCase(Adodc1.Recordset("GENERO")) = "FEMENINO" Then COMBO_GENERO.ListIndex =0
  5.     If UCase(Adodc1.Recordset("GENERO")) = "MASCULINO" Then COMBO_GENERO.ListIndex =1
  6.    
  7. 'ASUMO QUE EL PRIMER ITEM DEL COMBO_NIVEL_ESCOLAR ES "PREESCOLAR"
  8.    If UCase(Adodc1.Recordset("NIVELE")) = "PREESCOLAR" Then COMBO_NIVEL_ESCOLAR.ListIndex =0
  9.     If UCase(Adodc1.Recordset("NIVELE")) = "BASICO" Then COMBO_NIVEL_ESCOLAR.ListIndex =1
  10.     If UCase(Adodc1.Recordset("NIVELE")) = "UNIVERSITARIO" Then COMBO_NIVEL_ESCOLAR.ListIndex =2

Si estan enlazados con el ADO_CONTROL, los COMBO deben estar en ESTILO = 0 - DROPDOWN COMBO.
  #5 (permalink)  
Antiguo 20/05/2011, 00:49
Avatar de Shizuka  
Fecha de Ingreso: marzo-2011
Mensajes: 106
Antigüedad: 13 años
Puntos: 4
Respuesta: Duda para cargar image

Muchas gracias por responder :)

Las imàgenes si cargan, en todas las operaciones con el formulario, pero pasa algo raro al hacer actualizaciones, por que primero si carga, pero si hago otro cambio y luego me muevo a otro formulario y luego regreso a actualizaciones, y si presiono el boton para buscar con el inbutbox sale esto:

en los combos sale todo normal:



pero en el grid y en la base de datos no aparece





este es el codigo para el input box

Código vb:
Ver original
  1. Adodc1.Recordset.MoveFirst
  2.         dato = InputBox("INGRESE LA MATRÍCULA A BUSCAR :", "BUSQUEDA")
  3.        
  4.         If dato = "" Then Exit Sub
  5.        
  6.         Adodc1.Recordset.Find ("matricula=" + "'" + dato + "'")
  7.         If Adodc1.Recordset.EOF Then
  8.             MsgBox "LA MATRÍCULA QUE INGRESO NO EXISTE, POR FAVOR INTENTELO DE NUEVO", 64, "AVISO"
  9.             Adodc1.Recordset.MoveFirst
  10.             Exit Sub
  11.         End If
  12.        
  13.     'CARGAR LA IMAGEN, YA QUE SE ENCONTRO EL REGISTRO
  14.        Image1.Picture = LoadPicture(Label20.Caption)
  15.         Image2.Picture = LoadPicture(Label25.Caption)
  16.         Image3.Picture = LoadPicture(Label26.Caption)
  17.         Image4.Picture = LoadPicture(Label34.Caption)
  18.         Image5.Picture = LoadPicture(Label35.Caption)
  19.         Image6.Picture = LoadPicture(Label37.Caption)
  20.              
  21.      
  22.     'LOS COMBOS DEBEN ESTAR LLENOS
  23.      
  24.     'ASUMO QUE EL PRIMER ITEM DEL COMBO_GENERO ES "FEMENINO"
  25.        If UCase(Adodc1.Recordset("GENERO")) = "FEMENINO" Then Combo1.ListIndex = 0
  26.         If UCase(Adodc1.Recordset("GENERO")) = "MASCULINO" Then Combo1.ListIndex = 1
  27.        
  28.     'ASUMO QUE EL PRIMER ITEM DEL COMBO_NIVEL_ESCOLAR ES "PREESCOLAR"
  29.        If UCase(Adodc1.Recordset("NIVELE")) = "Maternal" Then Combo2.ListIndex = 0
  30.         If UCase(Adodc1.Recordset("NIVELE")) = "Preescolar" Then Combo2.ListIndex = 1
  31.         If UCase(Adodc1.Recordset("NIVELE")) = "Primaria" Then Combo2.ListIndex = 2

este el codigo para ejecutar la actualizacion

Código vb:
Ver original
  1. If Text1 = "" Or Text2 = "" Or Text3 = "" Or Text4 = "" Or Text5 = "" Or Text6 = "" Or Text7 = "" Or Text8 = "" Or Text9 = "" Or Text10 = "" Or Text11 = "" Or Text12 = "" Or Text13 = "" Or Text14 = "" Or Text15 = "" Or Text16 = "" Or Text17 = "" Or Text18 = "" Or Text19 = "" Or Text20 = "" Or Text21 = "" Or Text22 = "" Or Text23 = "" Or Text24 = "" Or Text25 = "" Or Text26 = "" Or Text27 = "" Or Combo1 = "" Or Combo2 = "" Or Combo3 = "" Or Combo4 = "" Or Combo5 = "" Or Label20 = "" Or Label25 = "" Or Label26 = "" Or Label34 = "" Or Label35 = "" Or Label37 = "" Then
  2. MsgBox "Faltan campos por llenar", vbInformation, "Aviso"
  3. Else
  4. With Adodc1
  5. If MsgBox("¿Está seguro de cambiar estos datos?", vbInformation + vbYesNoCancel, "Actualizar") = vbYes Then
  6. .Recordset.Update
  7. .Recordset.Requery
  8. End If
  9. End With
  10. End If



Pero creo que me salìa ese error por que en la actualizaciòn no habia usado el clear en los comboboxes del load tal y como me dijiste (solo en los demàs formularios)...ahhh esto esta raro, por que ya no me saliò error e_è seguramente era eso...Muchas gracias por tu ayuda :3 gracias mil n.n Si en algun futuro llego a tener problemas con esto mismo podrìa consultarte de nuevo?
__________________
Will you please tell me the way to the sky?

Última edición por Shizuka; 20/05/2011 a las 00:59
  #6 (permalink)  
Antiguo 20/05/2011, 06:22
Avatar de lokoman  
Fecha de Ingreso: septiembre-2009
Mensajes: 502
Antigüedad: 14 años, 6 meses
Puntos: 47
Respuesta: Duda para cargar image

Lo resolviste? OK!!
Si tienes algún problema no dudes en consultarnos!!
  #7 (permalink)  
Antiguo 20/05/2011, 10:28
Avatar de Shizuka  
Fecha de Ingreso: marzo-2011
Mensajes: 106
Antigüedad: 13 años
Puntos: 4
Respuesta: Duda para cargar image

Siiii!! tu còdigo fue de muchisima ayuda :3 muchas gracias de nuevo n_n
__________________
Will you please tell me the way to the sky?

Etiquetas: image, label
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:08.