Results 1 to 4 of 4

Thread: [RESOLVED] Internet Transfer Control (inet) from VB6 to Visual Studio 2008

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    13

    Resolved [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

  2. #2
    Lively Member
    Join Date
    Jun 2007
    Posts
    79

    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?

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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

  4. #4

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    13

    Re: Internet Transfer Control (inet) from VB6 to Visual Studio 2006

    Quote 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
  •  



Click Here to Expand Forum to Full Width