|
-
Feb 4th, 2009, 05:48 PM
#1
Thread Starter
New Member
[RESOLVED] Internet Transfer Control (inet) from VB6 to Visual Studio 2008
This works fine in VB6 but in vb2008 I wrote something wrong al Inet.execute line because I have 2 errors at the same line.... please help
Option Explicit
Private Declare Function InternetGetConnectedStateEx Lib "wininet.dll" (ByRef lpdwFlags As Long, ByVal lpszConnectionName As String, ByVal dwNameLen As Integer, ByVal dwReserved As Long) As Long
Public Function CheckInternetConnection() As Boolean
Dim aux As String * 255
Dim r As Long
r = InternetGetConnectedStateEx(r, aux, 254, 0)
If r = 1 Then
CheckInternetConnection = True
Else
CheckInternetConnection = False
End If
End Function
Private Sub Command1_Click()
If (CheckInternetConnection = True) Then
'This downloads the file and saves to your machine
On Error Resume Next
DownloadFile "http://www.plajacorbu.ro/secundare/distractieseara1.jpg", "C:\banner1.jpg"
On Error Resume Next
DownloadFile "http://www.plajacorbu.ro/link.txt", "C:\link.txt"
End If
End Sub
Public Sub DownloadFile(strURL As String, strDestination As String) 'As Boolean
Const CHUNK_SIZE As Long = 1024
Dim intFile As Integer
Dim lngBytesReceived As Long
Dim lngFileLength As Long
Dim strHeader As String
Dim b() As Byte
Dim i As Integer
DoEvents
'
With Inet1
.URL = strURL
.Execute , "GET", , "Range: bytes=" & CStr(lngBytesReceived) & "-" & vbCrLf
While .StillExecuting
DoEvents
Wend
strHeader = .GetHeader
End With
strHeader = Inet1.GetHeader("Content-Length")
lngFileLength = Val(strHeader)
DoEvents
lngBytesReceived = 0
intFile = FreeFile()
Open strDestination For Binary Access Write As #intFile
Do
b = Inet1.GetChunk(CHUNK_SIZE, icByteArray)
Put #intFile, , b
lngBytesReceived = lngBytesReceived + UBound(b, 1) + 1
DoEvents
Loop While UBound(b, 1) > 0
Close #intFile
End Sub
End Sub
-
Feb 4th, 2009, 07:53 PM
#2
Lively Member
Re: Internet Transfer Control (inet) from VB6 to Visual Studio 2006
I'd post this in the vb.NET section, also what's stopping you importing the control in manually from the IDE?
-
Feb 5th, 2009, 05:12 AM
#3
Re: Internet Transfer Control (inet) from VB6 to Visual Studio 2008
Thread moved from 'VB6 and Earlier' forum to 'VB.Net' (VB2002 and later) forum
-
Feb 5th, 2009, 11:16 AM
#4
Thread Starter
New Member
Re: Internet Transfer Control (inet) from VB6 to Visual Studio 2006
 Originally Posted by vbnewbie2007
I'd post this in the vb.NET section, also what's stopping you importing the control in manually from the IDE?
Thanks!!! the correct line is:
.Execute(strURL, "GET", strDestination, "Range: bytes=" & CStr(lngBytesReceived) & "-" & vbCrLf)
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
|