Reputation: 2490
Say I create a new instance of a class module. Within that instance block I call another sub which calls the functions in the class module. How can I accomplish this? Currently I can't figure out how it is done. The following is an overview of my code:
...
With New FTPClient
.ServerName = strServer
.UserName = strUserName
.Password = strPassword
.remoteDir = strRemoteFolder
.TransferType = "BINARY"
.OpenFTP
.OpenServer
Upload()
.CloseServer
.CloseFTP
End With
...
Function Upload()
...
.PutFile .remoteDir, currentFile, currentPath, "BINARY"
...
End Function
(.PutFile
is a method in FTPClient
.). Obviously it's having a bit of a fit and doesn't know what .PutFile
or .remoteDir
is. Is there some way of passing the instance of FTPClient
to Upload
?
Thanks,
Upvotes: 1
Views: 113
Reputation: 175936
You need to pass it if its scoped in the calling code:
set client = new FTPClient
with client
.ServerName = strServer
...
Upload(client)
Function Upload(client as FTPClient)
with client
.PutFile .remoteDir, currentFile, currentPath, "BINARY"
Upvotes: 2