Creating Your Own VBA Functions: ByVal
Public Function PowerDB(ByVal number As Double, n As Single) As Double
number = number ^ n
PowerDB = number
End Function
Private Sub testPower()
Dim number As Double
Dim n As Single
Dim result As Double
number = 2
n = 3
result = PowerDB(number, n)
MsgBox (number & "^" & n & " = " & result)
End Sub
Related examples in the same category