CodeItBetter Programming Another VB Programming Blog

How to find the receprocal of a given number

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
'Math - How to find the receprocal of a given number
Public Function Reciprocal(n As Double) As Variant
    If n <> 0 Then
        Reciprocal = 1 / n
    Else
        Reciprocal = CVErr(11)    ' Division By Zero error code
    End If
End Function
 
'How can I use this function:
'Dim res As Variant
'res = Reciprocal(CDbl(Text1.Text))
'If IsError(res) Then
'    MsgBox "Error #" & CLng(res)
'Else
'    MsgBox "Result is " & res
'End If
Filed under: Math Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.