Click to See Complete Forum and Search --> : FTP in VB5


Shah
December 1st, 1999, 07:52 AM
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

Chris Eastwood
December 1st, 1999, 08:09 AM
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

Shah
December 2nd, 1999, 02:34 AM
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.

Chris Eastwood
December 2nd, 1999, 02:43 AM
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

Shah
December 4th, 1999, 08:14 PM
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.

Chris Eastwood
December 5th, 1999, 12:02 PM
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

Shah
December 10th, 1999, 01:15 AM
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.

Chizl
December 10th, 1999, 01:17 AM
Why dont you just use the VB function Replace()?

--
Chizl
chizl@NOSPAM.karland.com
http://www.chizl.com/

Chizl
December 10th, 1999, 01:19 AM
My bad.. I have a simpler StringReplace function with less code if you want for VB5

--
Chizl
chizl@NOSPAM.karland.com
http://www.chizl.com/

Chris Eastwood
December 10th, 1999, 01:58 AM
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