I copy your function in Qlikview and the msgbox works.well
This macro is in VBScript, did you select VBScript?
If JScript is selected this function will not work.
I don't understand why you test a size of 12 figures? EAN13 didn't have 13 figures?
And after you loop from 1 to 12 to test if all character are figures, you need to loop from 1 to 13 to check all and to be right with the next if "If i = 13 Then" otherwise this condition will never be true.