Are there any coding standards for VBA within Excel?
Especially, I'd like to know when it is appropriate to output one or other of the standard error codes (viz#N/A, #REF!, #NAME?, #DIV/0!, #NULL!, #VALUE! and #NUM!) in response to bad i开发者_如何学Gonputs.
For example, which one is the best to be output in the event that a negative value is given as the second parameter to a Beta function?
#NUM!
would be the appropriate error.
From Excel's help:
#NUM!
Occurs with invalid numeric values in a formula or function.
For completeness, the descriptions of the other errors are as follows:
#####
Occurs when a column is not wide enough, or a negative date or time is used.
#VALUE!
Occurs when the wrong type of argument or operand is used.
#DIV/0!
Occurs when a number is divided by zero (0).
#NAME?
Occurs when Microsoft Excel doesn't recognize text in a formula.
#N/A
Occurs when a value is not available to a function or formula.
#REF!
Occurs when a cell reference is not valid.
#NULL!
Occurs when you specify an intersection of two areas that do not intersect. The intersection operator is a space between references.
精彩评论