The ONLY place in that which you showed us is here:
TrimNull = Left$(startstr, lstrlenW(StrPtr(startstr)))
Based on the syntax of the LEFT$ function, the item in red MUST be a number. If that function returns anything OTHER than a number, that is your syntax error.