
August 3rd, 2006, 11:40 AM
|
 |
**Wanted Wizard**
|
|
Join Date: Apr 2006
Location: Who knows...
|
|
Quote: | Originally Posted by chapman10s I have a VB executable that when I hit a button, it should transmit a file via FTP. I don't know VB 6 well, as this was developed by another programmer who is no longer with the company. Can anyone assist me?
I have some sample code but not sure where or how to modify it to make it work. There may be a simpler way to do it, so all help or advice is appreciated:
Here is the sample code:
Code:
Public Sub FTPFiles()
Dim f As frmMain
Set f = frmMain
Dim i As Integer
Dim ret
On Error GoTo errFTP
frmMain.txtMsgs = ""
ConnectToHostComputer "??", "??", "ftp.site.com", 21
If bFTPError Then
'connection failed
frmMain.Tag = "err"
sMsg = frmMain.txtModemMsg
sMsg = sMsg & vbNewLine & "There was an error connecting with the Host Computer."
frmMain.txtModemMsg = sMsg
ret = DoEvents()
Exit Sub
End If
f.Inet1.Execute , "DIR"
Do While frmMain.Inet1.StillExecuting = True
ret = DoEvents()
Loop
frmMain.txtMsgs = frmMain.txtMsgs & vbNewLine & DIRRemoteListing
sMsg = sMsg & vbNewLine & "Sending File(s) " & vbNewLine
f.txtModemMsg = sMsg
'//error log
For i = 1 To f.cboCoNo.ListCount
f.cboCoNo.ItemData(i - 1) = 0
If UCase(f.cboCoNo.List(i - 1)) = "TRANSMIT03" Then
sMsg = sMsg & vbNewLine & "Transmitting File 03..." & vbNewLine
f.txtModemMsg = sMsg
ret = DoEvents()
frmMain.Inet1.Execute , "PUT " & sPath & f.cboCoNo.List(i - 1) & " " & "CPN" & Format(Month(Date), "mm") & Format(Day(Date), "dd") & ".txt"
Do While frmMain.Inet1.StillExecuting = True
ret = DoEvents()
Loop
If FTPResponseComplete Then
sMsg = sMsg & vbNewLine & "FINISHED Sending File 03" & vbNewLine
f.cboCoNo.ItemData(i - 1) = 1
End If
End If
If UCase(f.cboCoNo.List(i - 1)) = "TRANSMIT05" Then
sMsg = sMsg & vbNewLine & "Transmitting File 05..." & vbNewLine
f.txtModemMsg = sMsg
ret = DoEvents()
frmMain.Inet1.Execute , "PUT " & sPath & f.cboCoNo.List(i - 1) & " " & "ACC" & Format(Month(Date), "mm") & Format(Day(Date), "dd") & ".txt"
Do While frmMain.Inet1.StillExecuting = True
ret = DoEvents()
Loop
If FTPResponseComplete Then
sMsg = sMsg & vbNewLine & "FINISHED Sending File 05" & vbNewLine
f.txtModemMsg = sMsg
f.cboCoNo.ItemData(i - 1) = 1
End If
End If
ret = DoEvents()
Next
CloseFTPConnection
Exit Sub
Can please someone help, as I don't follow this logic. |
Would this work: I have been trying to come up with a solution with some research..
Code:
Dim sRemote as string
Dim sLocal as string
Dim i as integer
flList.Path = "C:\xxx\" --- file location to send.
flList.Refresh
For i = 0 To flList.ListCount - 1
sRemote = flList.List(i)
sLocal = flList.Path & "\" & flList.List(i)
Inet1.Execute , "PUT """ & sLocal & """ " & sRemote
Next
|