Creating Your Own VBA Functions: ByVal : ByVal ByRef « Language Basics « VBA / Excel / Access / Word






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

1.ByVal and ByRef
2.Pass variable by value
3.Passing Arguments with ByVal and ByRef