使用 VB 6.0 将数组作为参数传递给 Class setter [英] Passing array as argument to a Class setter using VB 6.0
本文介绍了使用 VB 6.0 将数组作为参数传递给 Class setter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要传递一个 String
数组来使用它的 setter 方法设置一个类属性.数组是在模块中声明的,它使用 Redim Preserve
完美地设置了值.调用 Class setter 方法时会出错.如果我继续不设置数组数据类型,它会起作用.但我需要将数据类型声明为 String
.
I need to pass a String
array to set a class property using its setter method. Array was declared in Module and it's perfectly set the values using Redim Preserve
. When calling the Class setter method it gives error. If I continued to without setting array data type it worked. But I need to declare the data type as String
.
我收到一个编译错误类型不匹配:需要数组或用户定义类型."
I received a compile error "Type mismatch: array or user defined type expected."
Module
Dim sPageDetails() As String
' set some values to array
' Declare class instance
dim x as new X
with x
.SetPageNumberDetails(sPageDetails) ' assume SetPageNumberDetails is the setter method in class X
end with
End module
'class module start X
Private pageDetails() as String
' Setter for pageDetails array
Public Sub SetPageNumberDetails(ByRef sPageDetails() As String)
pageDetails= sPageDetails
End Sub
' Getter for pageDetails array
Public Function GetPageNumberDetails() As String()
GetPageNumberDetails= pageDetails
End Function
推荐答案
.SetPageNumberDetails(sPageDetails)
去掉括号:
.SetPageNumberDetails sPageDetails
这篇关于使用 VB 6.0 将数组作为参数传递给 Class setter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文