Also, from the sample you posted it would appear that you do not understand how to use User Defined Functions (UDFs). Please read the FAQ on How to use UDFs.