CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Thread: FTP in VB5

  1. #1
    Join Date
    Sep 1999
    Posts
    92

    FTP in VB5

    Hi,

    I am trying to transfer a specific file between a Win95 PC and a HP-UX machine running unix. The process should be running in the background withour any intervention from the user.

    Any help is very much appreciated.

    Thank


  2. #2
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: FTP in VB5

    If you have IE3 or later installed on the machine, you can use my code from :

    http://codeguru.developer.com/vb/articles/1852.shtml.

    The code is contained in a class module you can simply drop into your project and use straight away.



    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

  3. #3
    Join Date
    Sep 1999
    Posts
    92

    Re: FTP in VB5

    Hi Chris,

    Thank for the tip. I've downloaded the sample but could not load the project. I am getting the 'Retained' is an invalid key error.

    Pls help.




  4. #4
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: FTP in VB5

    That's because it was written in VB6. You'll need to remove the first 3 lines at the top of the Class module (before the Option Explicit).


    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

  5. #5
    Join Date
    Sep 1999
    Posts
    92

    Re: FTP in VB5

    Hi Chris,

    Thank you for the tip. In your cFTP.cls module you call a REPLACE() function, but there is no REPLACE() function in your class or form module.

    Pls help.


  6. #6
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: FTP in VB5

    I forgot about that - I don't think there's any other VB6 code in the project, but this VB5 code can be used to replace 'Replace' :


    public Sub ReplaceAll(byref sOrigStr as string, _
    byval sFindStr as string, _
    byval sReplaceWithStr as string, _
    optional bWholeWordsOnly as Boolean)
    '
    ' Replaces all occurances of sFindStr with sReplaceWithStr
    '
    Dim lPos as Long
    Dim lPos2 as Long
    Dim sTmpStr as string
    Dim bReplaceIt as Boolean
    Dim lFindStr as Long


    on error GoTo vbErrorHandler

    lFindStr = len(sFindStr)

    lPos2 = 1
    bReplaceIt = true
    sTmpStr = sOrigStr

    Do
    lPos = InStr(lPos2, sOrigStr, sFindStr)
    If lPos = 0 then
    Exit Do
    End If
    If bWholeWordsOnly then
    on error resume next
    If lPos = 1 Or (mid$(sOrigStr, lPos - 1, 1) = " ") then
    If (mid$(sOrigStr, lPos + lFindStr, 1) = " ") Or mid$(sOrigStr, lPos + lFindStr + 1, 1) = "" then
    bReplaceIt = true
    else
    bReplaceIt = false
    End If
    End If
    End If
    If bReplaceIt then
    If lPos > 1 then
    sTmpStr = Left$(sOrigStr, lPos - 1)
    else
    sTmpStr = ""
    End If
    sTmpStr = sTmpStr & sReplaceWithStr
    sTmpStr = sTmpStr & mid$(sOrigStr, lPos + lFindStr, len(sOrigStr) - (lPos + lFindStr - 1))
    sOrigStr = sTmpStr
    End If
    lPos2 = lPos + 1
    Loop
    sOrigStr = sTmpStr
    Exit Sub

    vbErrorHandler:
    Err.Raise Err.Number, "ReplaceAll", Err.Description


    End Sub





    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

  7. #7
    Join Date
    Sep 1999
    Posts
    92

    Re: FTP in VB5

    Hi,

    Can anybody give me a sample of how to transfer a file ie using FTP but WITHOUT overwriting it. The current FtpPutFile() will overwrite the file.

    Thank you.



  8. #8
    Join Date
    Dec 1999
    Location
    Dallas, Texas, USA
    Posts
    59

    Re: FTP in VB5

    Why dont you just use the VB function Replace()?

    --
    Chizl
    [email protected]
    http://www.chizl.com/

  9. #9
    Join Date
    Dec 1999
    Location
    Dallas, Texas, USA
    Posts
    59

    Re: FTP in VB5

    My bad.. I have a simpler StringReplace function with less code if you want for VB5

    --
    Chizl
    [email protected]
    http://www.chizl.com/

  10. #10
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: FTP in VB5

    But does it have the 'whole-words only' option like mine ? I'd be interested to see it.


    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured