Hello ' ' created tableData() 2d array in named "list"模块由getlist()函数。我想复制tableData()数组到主子。我认为首先我必须在主子中调用和运行函数,然后复制。但是ıdk怎么做你能帮我吗?我希望问题是清楚的。
'list module
Public Function getlist()
Dim tableData() As String
End Function
'Main Module
Sub Main()
Dim partlist() As String
partlist() = list.tableData() ' ıdk :)
End Sub
不需要使用全局变量
(1)你需要给函数赋一个返回值。在VBA中,这是通过将返回值赋值给函数来实现的。本身。
Public Function getlist() As String()
'any operations with array tableData()
Dim tableData() As String
(...)
getlist = tableData
End Function
(2)调用函数时,将返回值赋给主过程
Sub Main()
Dim partList() As String
partlist = getlist
(...)
End Sub
Public tableData() As String
Public Function getlist()
'any operations with array tableData()
End Function
Sub Main()
Dim partlist() As String
partlist() = list.tableData() ' ıdk :)
End Sub