Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 3rd, 2006, 09:15 AM
chapman10s's Avatar
chapman10s chapman10s is offline
**Wanted Wizard**
ASP Free God (5000 - 5499 posts)
 
Join Date: Apr 2006
Location: Who knows...
Posts: 5,410 chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)  Folding Points: 12139 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 4 Days 12 h 36 m
Reputation Power: 1331
Send a message via AIM to chapman10s Send a message via MSN to chapman10s
FTP a file in VB

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.

Reply With Quote
  #2  
Old August 3rd, 2006, 11:40 AM
chapman10s's Avatar
chapman10s chapman10s is offline
**Wanted Wizard**
ASP Free God (5000 - 5499 posts)
 
Join Date: Apr 2006
Location: Who knows...
Posts: 5,410 chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)chapman10s User rank is General 5th Grade (Above 100000 Reputation Level)  Folding Points: 12139 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 4 Days 12 h 36 m
Reputation Power: 1331
Send a message via AIM to chapman10s Send a message via MSN to chapman10s
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

Reply With Quote
  #3  
Old August 3rd, 2006, 11:36 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 57 m 26 sec
Reputation Power: 181
Do you get errors? Can you step through your code with the debugger?
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > FTP a file in VB


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT