Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP in VB

Status
Not open for further replies.

myasin78

Programmer
Jan 26, 2004
50
US
Hello all,

I am tring to write ftp module that ftps specific direcotry to an ftp server.
here is my code:

Private Sub cmdftp_Click()
Dim host_name As String

Enabled = False
MousePointer = vbHourglass

txtResult.Text = "Working"
txtResult.SelStart = Len(txtResult.Text)

DoEvents
host_name = "ftp://192.168.1.1"

inetFTP.UserName = txtusername.Text
inetFTP.Password = txtpasswd.Text

inetFTP.Execute , "Put " & all_dir_files

End Sub

Error "object required"
on line inetFTP.UserName = txtusername.Text


Any help will be appreciated.
thanks,
 
Where is inetFTP defined and instantiated ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I assumed it is a predefined object within VB.
 
At the top of every Declarations section put this instruction:
Option Explicit
and feel free to compile your project.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
here is what i got.
Error "variable undefined (inetFTP)".
I need to declare inetFTP as an ftp object is that correct?

thanks for your help.

 
You have first to reference it:
while in VBE, menu Tools -> References ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I have added the inetFtp control.
right now i have no errors nor result.
I don't know what is the probelm i have put in the test file that i am trying to ftp localy.

here is the new code.


Option Explicit

Private Sub cmdftp_Click()
Dim host_name As String

Enabled = False
MousePointer = vbHourglass

txtResult.Text = "Working"
txtResult.SelStart = Len(txtResult.Text)

host_name = "ftp://172.24.2.3"

InetFtp.URL = host_name

InetFtp.UserName = txtusername.Text
InetFtp.Password = txtpasswd.Text

txtResult.Text = txtResult.Text & vbCrLf & "processing..."
txtResult.SelStart = Len(txtResult.Text)

InetFtp.Execute , "put rep1.xml"

txtResult.Text = txtResult.Text & vbCrLf & "Done...\n"

End Sub

thanks,
 
again, Where is inetFTP defined and instantiated ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I added a control Inet (Microsoft Internet Transfer Protocol)and called it inetFtp. this is what defined inetFtp. I am not sure why do i have to defined in my code since its a control. I draged it from the control bar. anyway, i added more code to test the connection, here is my code, it seems that the connection was active.
I am looking into the linux server ftp log file to see if a conneciton was denied.

if this doesn't help you, thanks for your help, i will look more into it.


Private Sub InetFtp_StateChanged(ByVal State As Integer)

Select Case State
Case icError
txtResult.Text = "Error: " & _
InetFtp.ResponseCode & vbCrLf & InetFtp.ResponseInfo

Case icConnecting
txtResult.Text = "Connecting"
Case icDisconnected
txtResult.Text = "Diconnecting"
Case icRequestSent
txtResult.Text = "Request Sent"
Case icResponseCompleted
txtResult.Text = InetFtp.ResponseInfo
End Select
Enabled = True
MousePointer = vbDefault


End Sub
 
I wanted to thank you for you help.
I finally get it to work.
here is my code, in case if someone else needs it.

Private Sub cmdftp_Click()
txtResult.Text = "Working"
txtResult.SelStart = Len(txtResult.Text)

With InetFtp
.AccessType = icUseDefault
.Protocol = icFTP
.RemoteHost = "172.24.2.3"
.RequestTimeout = 600
.UserName = txtusername.Text
.Password = txtpasswd.Text
.Execute , "Put c:\rep1.xml rep1.xml"
End With

End Sub
Private Sub InetFtp_StateChanged(ByVal State As Integer)

Select Case State
Case icError
txtResult.Text = "Error: " & _
InetFtp.ResponseCode & vbCrLf & InetFtp.ResponseInfo
Case icConnecting
txtResult.Text = "Connecting"
Case icDisconnected
txtResult.Text = "Diconnecting"
Case icRequestSent
txtResult.Text = "Request Sent"
Case icResponseCompleted
txtResult.Text = "Complete..."
End Select
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top