|
-
May 17th, 2008, 11:21 AM
#1
Thread Starter
Lively Member
link as a image?
how would i save a pictures url as a image file in vb like if i have
HTML Code:
http://www.google.com/intl/en_ALL/images/logo.gif
and i want it so when something happends that url gets saved as a image how would i go about that
-
May 17th, 2008, 11:38 AM
#2
Re: link as a image?
On a Form put a Command button, a Picturebox Control, and an Inet Control
Code:
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" _
(ByVal pCaller As Long, _
ByVal szURL As String, ByVal _
szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Private Sub DownloadFile(URL As String, SaveAsFile As String)
Dim b As Long
b = URLDownloadToFile(0, URL, SaveAsFile, 0, 0)
End Sub
Private Function bFileExists(sFile As String) As Boolean
On Error Resume Next
bFileExists = ((GetAttr(sFile) And vbDirectory) = 0)
End Function
Private Function RemoveURLPath(ByVal FullPath As String) As String
Dim Pos As Long
Pos = InStrRev(FullPath, "/")
If Pos > 0 Then
RemoveURLPath = Mid$(FullPath, Pos + 1)
End If
End Function
Private Sub Command1_Click()
Dim sURL As String, SaveAs As String
sURL = "http://www.google.com/intl/en_ALL/images/logo.gif"
SaveAs = RemoveURLPath(sURL)
On Error Resume Next
If bFileExists(SaveAs) = False Then DownloadFile sURL, SaveAs
If bFileExists(SaveAs) = True Then Picture1.Picture = LoadPicture(SaveAs)
End Sub
-
May 17th, 2008, 12:02 PM
#3
Re: link as a image?
No need for the Inet control in your example.
-
May 17th, 2008, 12:30 PM
#4
Re: link as a image?
Oh yeah, I got that from a project that had Inet on it but for other reasons. Good point there, DR.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|