传递 Class 模块的实例
Passing instance of Class Module
假设我创建了一个 class 模块的新实例。在该实例块中,我调用了另一个调用 class 模块中的函数的子程序。我怎样才能做到这一点?目前我无法弄清楚它是如何完成的。以下是我的代码的概述:
...
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
吗?
谢谢,
如果它在调用代码中的作用域,则需要传递它:
set client = new FTPClient
with client
.ServerName = strServer
...
Upload(client)
Function Upload(client as FTPClient)
with client
.PutFile .remoteDir, currentFile, currentPath, "BINARY"
假设我创建了一个 class 模块的新实例。在该实例块中,我调用了另一个调用 class 模块中的函数的子程序。我怎样才能做到这一点?目前我无法弄清楚它是如何完成的。以下是我的代码的概述:
...
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
吗?
谢谢,
如果它在调用代码中的作用域,则需要传递它:
set client = new FTPClient
with client
.ServerName = strServer
...
Upload(client)
Function Upload(client as FTPClient)
with client
.PutFile .remoteDir, currentFile, currentPath, "BINARY"