The function below, cInt2, does just that and can be used in the same way as the regular cInt function.
function cInt2(strInput) 'Remove any trailing or leading spaces strInput = trim(strInput)
'If the input is null, blank, or not a number then set it to zero if strInput = "" or isNull(strInput) or not isNumeric(strInput) then strInput = "0"
' Convert it to an integer using the regular cInt function and return it. cInt2 = cInt(strInput) end function |
This function could also be adapted to cater for converting the “on” value passed by checked checkboxes to a given integer.