Ver Mensaje Individual
  #2 (permalink)  
Antiguo 23/05/2011, 07:40
Avatar de lokoman
lokoman
 
Fecha de Ingreso: septiembre-2009
Mensajes: 502
Antigüedad: 14 años, 7 meses
Puntos: 47
Respuesta: cargar una imagen desde una url en un picture

Hola!!
1-Agrega un control Inet (Microsoft Internet Transfer Control)
2-Agrega un Command
2-Agrega el CODE

Código vb:
Ver original
  1. Private txtUrl As String
  2.  
  3. Private Sub Command_Click()
  4.     txtUrl = "http://yeray.venimdepoble.com/Imagenes/goldman2.jpg"
  5.     With Inet
  6.         .AccessType = icUseDefault
  7.         .URL = txtUrl
  8.         .Execute , "GET"
  9.     End With
  10. End Sub
  11.  
  12. Private Sub Inet_StateChanged(ByVal State As Integer)
  13.     Dim vtData As Variant, nomArchivo As String
  14.     Dim bDone As Boolean, tempArray() As Byte
  15.     nomArchivo = Right(Inet.URL, Len(Inet.URL) - InStrRev(Inet.URL, "/"))
  16.  
  17.     Select Case State
  18.     Case icResponseCompleted
  19.         bDone = False
  20.         filesize = Inet.GetHeader("Content-length")
  21.         contenttype = Inet.GetHeader("Content-type")
  22.  
  23.         Open App.Path & "\" & nomArchivo For Binary As #1
  24.             vtData = Inet.GetChunk(1024, icByteArray)
  25.    
  26.             DoEvents
  27.    
  28.             If Len(vtData) = 0 Then
  29.                 bDone = True
  30.             End If
  31.            
  32.             Do While Not bDone
  33.                 tempArray = vtData
  34.                 Put #1, , tempArray
  35.                 vtData = Inet.GetChunk(1024, icByteArray)
  36.                 DoEvents
  37.    
  38.                 If Len(vtData) = 0 Then
  39.                     bDone = True
  40.                 End If
  41.             Loop
  42.         Close #1
  43.  
  44.         'Carga la imagen
  45.        img.Picture = LoadPicture(App.Path & "\" & nomArchivo)
  46.  
  47.         Kill App.Path & "\" & nomArchivo
  48.     End Select
  49. End Sub

Puedes ver mas metodos en:
http://www.recursosvisualbasic.com.a...gar-imagen.htm