|
-
May 26th, 2006, 07:12 AM
#1
Thread Starter
Addicted Member
[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:
Screen.MousePointer = vbHourglass
ProgressBar1.Value = 0
'ProgressBar1.Visible = True 'show progressbar
'This downloads the file and saves to your machine
Timer1.Enabled = True
If filen = "adam.exe" Then
DownloadFile "http://www.guitar.gratisplaneten.com/adam/" & filen, App.Path & "\adam_.exe"
Screen.MousePointer = vbDefault
And here's the DownloadFile code:
VB Code:
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
DownloadProgress (Round((lngBytesReceived / lngFileLength) * 100))
DoEvents
Loop While UBound(b, 1) > 0
Close #intFile
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
-
May 26th, 2006, 07:16 AM
#2
Fanatic Member
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:
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
-
May 26th, 2006, 07:30 AM
#3
Thread Starter
Addicted Member
-
May 26th, 2006, 07:36 AM
#4
Fanatic Member
Re: Wierd download
 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
-
May 26th, 2006, 07:37 AM
#5
Thread Starter
Addicted Member
Re: [RESOLVED] Wierd download
okey, tnx!
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
|