支持返回功能

时间:2020-05-30 16:59:38

标签: vba return return-value

我在VBA上的返回功能遇到了一些麻烦,希望有人能够帮助我解决问题。

功能如下:

    listA = [1, 2, 3 , 4];
    listB = ['a', 'b', 'c']
    this.combined = this.listA.map((x, i)=> {
          return {"a": x, "b": this.listB[i]}
    } );

问题摘要:

  • 返回功能以“红色”突出显示,我无法运行任何调用该功能的子程序(参见附图)
  • 非常确定代码是正确的,但是我根本不明白为什么我总是收到错误消息

知道为什么会这样吗?

任何帮助将不胜感激:)

enter image description here

1 个答案:

答案 0 :(得分:1)

使用Sqr函数..并在VBA中没有Return关键字

Sub Test()
    Debug.Print Hypotenuse(5, 3)
End Sub

Function Hypotenuse(side1 As Double, side2 As Double) As Double
    Hypotenuse = Sqr((side1 ^ 2) + (side2 ^ 2))
End Function