Results 1 to 5 of 5

Thread: [RESOLVED] Wierd download

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2006
    Location
    Sweden
    Posts
    173

    Resolved [RESOLVED] Wierd download

    I'm using a Inet thing to download a file. The file is called brain.txt.

    here's the "ignition code":

    VB Code:
    1. Screen.MousePointer = vbHourglass
    2.  
    3. ProgressBar1.Value = 0
    4.  
    5. 'ProgressBar1.Visible = True 'show progressbar
    6.  
    7. 'This downloads the file and saves to your machine
    8. Timer1.Enabled = True
    9. If filen = "adam.exe" Then
    10. DownloadFile "http://www.guitar.gratisplaneten.com/adam/" & filen, App.Path & "\adam_.exe"
    11. Screen.MousePointer = vbDefault

    And here's the DownloadFile code:

    VB Code:
    1. Public Sub DownloadFile(strURL As String, strDestination As String) 'As Boolean
    2. Const CHUNK_SIZE As Long = 1024
    3. Dim intFile As Integer
    4. Dim lngBytesReceived As Long
    5. Dim lngFileLength As Long
    6. Dim strHeader As String
    7. Dim b() As Byte
    8. Dim i As Integer
    9.  
    10. DoEvents
    11.    
    12. With Inet1
    13.    
    14. .url = strURL
    15. .Execute , "GET", , "Range: bytes=" & CStr(lngBytesReceived) & "-" & vbCrLf
    16.        
    17. While .StillExecuting
    18. DoEvents
    19. Wend
    20.  
    21. strHeader = .GetHeader
    22. End With
    23.    
    24.    
    25. strHeader = Inet1.GetHeader("Content-Length")
    26. lngFileLength = Val(strHeader)
    27.  
    28. DoEvents
    29.    
    30. lngBytesReceived = 0
    31.  
    32. intFile = FreeFile()
    33.  
    34. Open strDestination For Binary Access Write As #intFile
    35.  
    36. Do
    37. b = Inet1.GetChunk(CHUNK_SIZE, icByteArray)
    38. Put #intFile, , b
    39. lngBytesReceived = lngBytesReceived + UBound(b, 1) + 1
    40.  
    41. DownloadProgress (Round((lngBytesReceived / lngFileLength) * 100))
    42. DoEvents
    43. Loop While UBound(b, 1) > 0
    44.  
    45. Close #intFile
    46.  
    47. End Sub


    My problem is that when I've downloaded the file, everywhere in it where there should be enters, there's instead a wierd box sign ( almost like this [] ).

    How can I download the file normal, so I get it as it should be?

    Plz help!

    //Alex
    Please Help Us To Save Ana

    You never fail before you stop trying!
    ______________________________
    If I manage to say something good...please reputate
    ______________________________
    ________

    Links:
    Intellithing
    Digitala.nu
    Norrköpings Goklubb
    WoW Trade Center

  2. #2
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722

    Re: Wierd download

    It is normal.

    For one, your textbox should be set to multiline.

    Second, it could be only Chr(10) or Chr(13). Try this:

    VB Code:
    1. text1.text = replace(text1.text, Chr(10), vbCrLf)

    If it doesn't work, try changing Chr(10) to Chr(13) in the same code

    r0ach™
    Don't forget to rate the post

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2006
    Location
    Sweden
    Posts
    173

    Lightbulb Re: Wierd download

    tnx man! your replace code works perfect! I'll reputate at once!

    btw, it's Chr(13) that is enter.
    Please Help Us To Save Ana

    You never fail before you stop trying!
    ______________________________
    If I manage to say something good...please reputate
    ______________________________
    ________

    Links:
    Intellithing
    Digitala.nu
    Norrköpings Goklubb
    WoW Trade Center

  4. #4
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722

    Re: Wierd download

    Quote Originally Posted by cyber_alex
    btw, it's Chr(13) that is enter.
    Actually, vbCrLf (enter) = Chr(10) and Chr(13)

    Most end-of-lines are. This is what the textbox is looking for. Some files have only Chr(10) and others only Chr(13). I usually just replace them with vbCrLf

    r0ach™
    Don't forget to rate the post

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Apr 2006
    Location
    Sweden
    Posts
    173

    Re: [RESOLVED] Wierd download

    okey, tnx!
    Please Help Us To Save Ana

    You never fail before you stop trying!
    ______________________________
    If I manage to say something good...please reputate
    ______________________________
    ________

    Links:
    Intellithing
    Digitala.nu
    Norrköpings Goklubb
    WoW Trade Center

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