无法将函数的数组结果分配给数组 [英] Can't assign array result of function to an array

查看:61
本文介绍了无法将函数的数组结果分配给数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将函数的数组结果分配给数组.如果我尝试将结果数组的一个元素分配给我的数组,则效果很好,但是在尝试将整个结果数组分配给我的数组时,它返回错误(无法分配给数组").

I'm trying to assign array result of function to an array. It works fine, if i try to assign one element of result array to my array, but it returns error while trying to assign whole result array to my array ("Can't assign to array").

Sub test()
Dim lol(6) as Double
lol = Hehe2()
End Sub

Function Hehe2() As Double()
Dim Zliczacz(1 To 6) As Double
Zliczacz(1) = 1 / 2
Zliczacz(2) = 1 / 2
Zliczacz(3) = 1 / 2
Zliczacz(4) = 1 / 2
Zliczacz(5) = 1 / 2
Zliczacz(6) = 1 / 2
Hehe2 = Zliczacz()
End Function

推荐答案

如果将接收数组声明为动态数组并且具有相同类型,则只能将一个数组分配给另一个数组.您的是固定的,因此将无法使用.您需要使用:

You can only assign one array to another if the receiving array is declared as dynamic and of the same type. Yours is fixed, so it won't work. You need to use:

Dim lol() as Double

这篇关于无法将函数的数组结果分配给数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆