我有一个具有Double
固定大小数组的类,例如
Private m_values(8) as Double
数组的Let
和Get
方法的正确语法是什么?
Public Property Let Values (RHS(8) as Double)
m_values = RHS
End Property
Public Property Get Values() as Double
Values = m_values
End Property
语法的具体部分我不清楚:
一个。在Let
方法中,RHS(8) as Double
传递8 Double
数组的正确方法是什么?
湾我可以使用赋值将一个数组复制到另一个数组吗? (例如m_values = values
)
C。对于Get
方法,声明as Double
的函数是正确的还是as Double(8)
?
答案 0 :(得分:4)
声明可以保存数组的属性的唯一方法是Variant
属性。
Private m_values As Variant
Public Property Let Values(RHS As Variant)
m_values = RHS
End Property
Public Property Get Values() As Variant
Values = m_values
End Property
Public Sub Test()
Dim x(8) As Double
x(1) = 123.55
x(2) = 456.45
x(5) = 789.66
x(8) = 123.777
' assign value to property
Values = x
' get value from property
Dim y() As Double
y = Values
Dim i As Integer
For i = 0 To UBound(y)
Debug.Print y(i)
Next
End Sub
答案 1 :(得分:2)
尽量遵守以下规则:
public function getTablesCreationOrderAction()
{
$app = New Application($this->get('kernel'));
$app->setAutoExit(false);
$input = New ArrayInput(['command' => 'doctrine:schema:create',
'--dump-sql'=>true]);
$output = New BufferedOutput();
$app->run($input, $output);
$rst = $output->fetch();
$schema = explode('CREATE TABLE ', $rst);
$tables = [];
foreach ($schema as $tableDef)
{
$tables[] = explode(' (', $tableDef)[0];
}
unset($tables[0]); // empty
var_dump($tables);
die();
}
这些规则在将变量(作为参数)传递给另一个属性,函数或子例程时也起作用。这也意味着您不能将Get Property声明为数组,您应该将其声明为Variant类型。