Illegal function call - (%ERR_ILLEGALFUNCTIONCALL) - This is a catch-all error related to passing an inappropriate argument to some statement or function.
There are many things that can cause an Error 5, for example:
Trying to set TIME$ to an invalid value.
Attempting to use the WIDTH# statement on a
The run-time execution of a LET, LET (with Objects), LET (with Types), LET (with Variants), or OBJECT statement failed (see OBJRESULT and OBJRESULT$ to obtain an extended error code).