从 VBA 教程之一中,我了解到应首先将连续数字的变量声明为整数:
Dim mynumber as integer
但是,请看这段代码:
Sub math()
A = 23
B = 2
ABSumTotal = A + B
strMsg = "The answer is " & "$" & ABSumTotal & "."
MsgBox strMsg
strMsg = "The answer is " & "$" & Sqr(ABSumTotal) & "."
MsgBox strMsg
End Sub
这里没有将变量声明为整数,但它仍然可以正常工作。为什么会这样?