JenniferMurphy
Well-known Member
- Joined
- Jul 23, 2011
- Messages
- 2,404
- Office Version
- 365
- Platform
- Windows
I have a function defined like this:
If it is called from a worksheet and passed a non-integer (=test(5.5)), it happily rounds it to 6 and returns 7. I was expecting a #Value error.
Can I get VBA to reject non-integer data if I declare the parameter as “Integer”?
If not, do I have to test every parameter inside the function to make sure it’s the right type? I thought that was what the declaration was for.
Puzzled...
Code:
Function Test(p1 as Integer) as Integer
test = p1 + 1
End Function
Can I get VBA to reject non-integer data if I declare the parameter as “Integer”?
If not, do I have to test every parameter inside the function to make sure it’s the right type? I thought that was what the declaration was for.
Puzzled...