Changes

Internet Transfer Control in VB6

1,515 bytes added, 17:41, 24 November 2010
Reverted edits by [[Special:Contributions/Atekysepiko|Atekysepiko]] ([[User_talk:Atekysepiko|Talk]]); changed back to last version by [[User:Admin|Admin]]
The following lines were added (+) and removed (-):
== Inet Transfer Control ==== Inet Transfer Control / ITC == The '''[http://support.microsoft.com/kb/q163653/ Internet Transfer ActiveX Control]''' component can be used to download files from the Internet.  ITC can be used to send and retrieve documents across the net.  ITC supports both synchronous and asynchronous transfers. In synchronous transfer, you can make the system wait until the transfer is complete, and in asynchronous transfer, the system can work as usual while the file is transferred in the background.in order by state number (same as above):<big><big> '  0 ........................ stateless '  1 .......... checking remote address '  2 .......... remote address accepted '  3 ....................... connecting '  4 ........................ connected '  5 .................. data requesting '  6 ..................... request sent '  7 ............... response receiving '  8 ................ response received '  9 .................... disconnecting ' 10 ..................... disconnected ' 11 ............................ error ' 12 .......................... success</big></big> Here is a State to Text Function you may find useful: Private Function StateText(n As Integer) As String  Select Case n    Case 0:    StateText = "stateless"    Case 1:    StateText = "checking remote address"    Case 2:    StateText = "remote address accepted"    Case 3:    StateText = "connecting"    Case 4:    StateText = "connected"    Case 5:    StateText = "data requesting"    Case 6:    StateText = "data sent"    Case 7:    StateText = "response receiving"    Case 8:    StateText = "response received"    Case 9:    StateText = "disconnecting"    Case 10:    StateText = "disconnected"    Case 11:    StateText = "error"    Case 12:    StateText = "success"    Case Else:    StateText = "that's weird"  End Select End FunctionExample 3: VBA, Retrieve a File from an FTP SiteExample 3: Working example to Retrieve a File from an FTP Site   <nowiki>Private Sub Form_Load()</nowiki>   <nowiki> strExe = "GET " & strSrc & " " & strDst</nowiki>   <nowiki>   ' Set a reference to the internet transfer control.</nowiki>   <nowiki> With inet</nowiki>   <nowiki>   Set objFTP = Me!axFTP.Object</nowiki>   <nowiki>   .Protocol = icFTP</nowiki>  <nowiki>End Sub</nowiki>   <nowiki>   .UserName = "username"</nowiki>  <nowiki></nowiki>   <nowiki>   .Password = "password"</nowiki>  <nowiki>Private Sub cmdGetFile_Click()</nowiki>   <nowiki>   .RemoteHost = "ftp.robotz.com"</nowiki>  <nowiki>  Dim strSite As String</nowiki>   <nowiki>   .Execute , strExe</nowiki>  <nowiki>  Dim strFile As String</nowiki>   <nowiki> End With</nowiki>  <nowiki>  strSite = Me!txtFTPSite</nowiki>    <nowiki>   strFile = Me!txtFileName</nowiki>&nbsp;   <nowiki>   objFTP.Protocol = icFTP</nowiki>    <nowiki>   objFTP.URL = strSite</nowiki>You can tell the program to continue while waiting for the connection to finish.   <nowiki>   objFTP.Execute strSite, "Get " & strFile & " C:\" & strFile</nowiki>    <nowiki>End Sub</nowiki> 'Essential to avoid tying up the system  <nowiki></nowiki> Do Until inet.StillExecuting = False ' WAIT Downloading..  <nowiki>Private Sub axFTP_StateChanged(ByVal State As Integer)</nowiki>  DoEvents  <nowiki>  ' Display a message when the transfer is finished.</nowiki> Loop  <nowiki>  If State = 12 Then Msgbox "File Transferred"</nowiki>  <nowiki>End Sub</nowiki>
Bureaucrat, administrator
16,192
edits