# VBForums CodeBank > CodeBank - Visual Basic 6 and earlier >  VB6 - FTP Class for people doing FTP - FTP made easy

## jian2587

NOTE: Add reference to FTPC.dll first.

VB Code:
'To use the object, declare it then create a new instance of it
Dim WithEvents objFTPC As FTPClient
Set objFTPC = New FTPClient
'To connect, supply it with required parameters
objFTPC.Username = "Anonymous"
objFTPC.Password = "Guest"
objFTPC.PassiveMode = True
objFTPC.RemoteHost = "ftp.ftphost.com"
objFTPC.RemotePort = 21
objFTPC.Connect
'To upload data,
objFTPC.OpenDataConnection
'Wait for Data socket to be connected
Do Until objFTPC.DataState = DS_CONNECTED
    DoEvents
Loop
'Upload data
objFTPC.UploadFile "readme.txt"
'Then upload ur data whenever NeedData event is fired
Private Sub objFTPC_NeedData() 
objFTPC.SendData "My data"
End Sub
 'To download data,
objFTPC.OpenDataConnection
'Wait for Data socket to be connected
Do Until objFTPC.DataState = DS_CONNECTED
    DoEvents
Loop
'Download data
objFTPC.DownloadFile "readme.txt"
'Then download ur data whenever IncomingData event is fired
Private Sub objFTPC_IncomingData(BytesTotal As Long)
Dim sData As String
objFTPC.GetData sData
End Sub
'That cover the basics. For more advance functions, post it here

----------


## v8maro

when I get to SckCmd.GetData sData in SckCmd_DataArrival i keep getting the following error:

? err.Description
Wrong protocol or connection state for the requested transaction or request
? err.Number
 40006 

Does this mean the program has yet to connect to the winsock?

----------


## jian2587

it probably means it's already connected and closed.
I've done a complete rewrite. Check this link:
http://www.vbforums.com/showthread.php?t=278007

----------


## chito

sir can u explain to the code above..one by one for me to understand all the code..stands for...

Many thanks,
-chito

----------


## Lookover.at

Hello.

First of all:
Thanks fpr your work.
But im sorry, i could not handle it.
It was tooo curious and complicated.

Then i found this:
http://www.mcmillan.org.nz/paradoxes/code/FTPClass.html
and its realy great, and from my point of view, its much better and easyer.

Thanks, and best wished from vienna.
Tom www.lookover.at

----------


## bye360

to lookover.at 

this code http://www.mcmillan.org.nz/paradoxes/code/FTPClass.html
    is not an asynchronous..  it easyer ,but,More bad

----------


## evry1falls

have you check this out

----------


## SystemX

Hi, i am trying to add this .dll but get an error and it wont add it ?



What have i done wrong ?

Thanks

----------


## dilettante

Well for one thing you're posting in a VB6 section and you're using VBdotNet.

But this also isn't the best place to ask a question.  Once a CodeBank thread goes inactive it's really for reference and not actively monitored.

----------


## evry1falls

Take a look at this post : http://www.vbforums.com/showthread.p...d-delete-files

----------

