0
我是编程中的新手。我在做一些VB代码的练习,但是我得到了关于这个主题的错误。编译器错误:声明的预期结束
以下是该错误在返回表达“数学”被高亮显示的代码
Function hypotenuse(ByVal a As Single, ByVal b As Single) As Single
Return Math.Sqrt((a^2) + (b^2))
End function
。
我是编程中的新手。我在做一些VB代码的练习,但是我得到了关于这个主题的错误。编译器错误:声明的预期结束
以下是该错误在返回表达“数学”被高亮显示的代码
Function hypotenuse(ByVal a As Single, ByVal b As Single) As Single
Return Math.Sqrt((a^2) + (b^2))
End function
。
在VB6/VBA中,函数的返回值变量名称是函数名称本身。
Function hypotenuse(ByVal a As Single, ByVal b As Single) As Single
hypotenuse = Math.Sqr((a^2) + (b^2))
End Function
非常感谢您的支持,我不知道我认为这两种方式都可以接受。是的,当我使用函数名称就像一个魅力。我很感谢你的帮助 – Ali