我是一个很长时间的狂热Excel用户,但我刚刚开始学习VBA.我使用以下代码但在尝试运行时遇到错误Sub test:
编译错误:未定义变量
你能帮我弄清楚出了什么问题吗?
Option Explicit
Function toFarenheit(degrees)
toFarenheit = (9 / 5) * degrees + 32
End Function
Function toCentigrade(degrees)
toCentigrade = (5 / 9) * degrees - 32
End Function
Sub test()
answer = toCentigrade(55)
MsgBox answer
End Sub
Run Code Online (Sandbox Code Playgroud)