Changed to leftstr (edit 1.text+key, 1) =' 0'
Because it was empty at first, it judged editing before you pressed the key, so there was an error, so just add the pressed key and it will be OK!