Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReservd As Long, ByVal lpfnCB As Long) As Long
Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then DownloadFile = True
End Function
Private Sub Form_Load()
DownloadFile "http://www.xxx.com/mapa.jpg", "c:\Imagen.jpg"
Image1 = LoadPicture("C:\imagen.jpg")
If App.PrevInstance Then Unload Me
End Sub
Private Sub Form_Click()
Unload Me
End Sub
He conseguido reducir el codigo hasta esto. Lo que pasa que cuando depuro se me queda pillado en el Private Sub Form_Load
Sin embargo, cambio el Form_Load por Form_Long y entonces me funciona. Porque?? Llevó desde anoche con esto del Visual Basic...no me entero de mucho
Si lo dejo asi
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReservd As Long, ByVal lpfnCB As Long) As Long
Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then DownloadFile = True
End Function
Private Sub Form_Long()
DownloadFile "http://www.meteoclimatic.com/bot/mapa.jpg", "c:\Imagen.jpg"
Image1 = LoadPicture("C:\imagen.jpg")
If App.PrevInstance Then Unload Me
End Sub
Private Sub Form_Click()
Unload Me
End Sub
Se me queda pillado en el Ultimo Private sub. Tiene narices la cosa
Gracias!