Access9001
Registered User.
- Local time
- Yesterday, 20:11
- Joined
- Feb 18, 2010
- Messages
- 268
So I know there's a fact() function but bear with me -- there's a reason why I need to use a user-made function, here, but I don't need to get into it.
But I am using the following:
Function facty(expression As Variant) As Variant
Dim I As Double
Dim bNum As Variant
If Not IsError(Evaluate(expression)) Then
bNum = Evaluate(expression)
If InStr(1, bNum, ".") = 0 Then
If bNum = 0 Then
facty = 1
Exit Function
End If
If bNum < 0 Then Exit Function
facty = 1
For I = 1 To bNum
facty = facty * I
Next
Else
facty = "errorthrow"
End If
Else
facty = "errorthrow"
End If
End Function
Now this works great when you use it in the Excel spreadsheets, but if I use another code:
msgbox evaluate("facty(4+5)")
it doesn't work. Why?
But I am using the following:
Function facty(expression As Variant) As Variant
Dim I As Double
Dim bNum As Variant
If Not IsError(Evaluate(expression)) Then
bNum = Evaluate(expression)
If InStr(1, bNum, ".") = 0 Then
If bNum = 0 Then
facty = 1
Exit Function
End If
If bNum < 0 Then Exit Function
facty = 1
For I = 1 To bNum
facty = facty * I
Next
Else
facty = "errorthrow"
End If
Else
facty = "errorthrow"
End If
End Function
Now this works great when you use it in the Excel spreadsheets, but if I use another code:
msgbox evaluate("facty(4+5)")
it doesn't work. Why?
Last edited: