|
-
Apr 3rd, 2000, 04:40 PM
#2
Lively Member
Add a winsock control to you form and a text box and use some code such as...
Winsock = SckSocket
Text = DownloadText
Text = FilenameText
Timer = DownloadTimer
'These go into Declarations on the form
Dim TotalBytes as Long
Dim TempBytes as Long
Dim DownloadSpeed as Integer
'Being main code
Private Sub Form_Load()
DownloadSpeed = 0
TempBytes = 0
TotalBytes = 0
DownloadText.Text = ""
DownloadTimer.Enabled = False
DownloadTimer.Interval = 1000
End Sub
Private Sub ConnectCmd_Click()
SckSocket.connect "www.webserver.com", 80
Me.Caption = "Connecting to host..."
End Sub
Private Sub SckSocket_Connect()
Me.Caption = "Connected to: " & SckSocket.RemoteHostIP
SckSocket.SendData "GET /" & FileNameTxt.Text & " HTTP/1.0" & vbcrlf & vbcrlf
DownloadTimer.Enabled = True
End Sub
Private Sub SckSocket_DataArrival(bytes as long)
TempBytes = bytes
TotalBytes = TotalBytes + Int(bytes)
Me.Caption = "Downloading: " & TotalBytes " bytes complete. Speed: " & DownloadSpeed
SckSocket.GetData TempStr, VbString
DownloadText.Text = DownloadText.Text & VbString
End Sub
Private Sub SckSocket_Close()
Me.Caption = "Download Complete! " & TotalBytes & " were downloaded."
End Sub
Private Sub DownloadTimer_Timer()
DownloadSpeed = Int(TempBytes / 1024)
End Sub
Make a form, add the above objects, run it
and put in the Text box for "FileNameText" something like..
/index.html
Note: That code was off the top of my head and has NOT been tested. Perhaps someone else can repost the code so that it supports Binary files and not just a html/text file.
Regards,
 Paul Rivoli 
---------------------
[email protected]
http://members.dingoblue.net.au/~privoli
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
|