假设我创建了一个类模块的新实例。在该实例块中,我调用另一个调用类模块中的函数的子。我怎么能做到这一点?目前我无法弄清楚它是如何完成的。以下是我的代码概述:
...
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
是FTPClient
中的方法。)。显然它有点合适,并且不知道.PutFile
或.remoteDir
是什么。有没有办法将FTPClient
的实例传递给Upload
?
谢谢,
答案 0 :(得分:2)
如果它的作用域在调用代码中,则需要传递它:
set client = new FTPClient
with client
.ServerName = strServer
...
Upload(client)
Function Upload(client as FTPClient)
with client
.PutFile .remoteDir, currentFile, currentPath, "BINARY"