if txtD1.text <> " " or txtP1.text <> 0 then

In the above case you test a zero value

If you want to test a 0 character:

if txtD1.text <> " " or txtP1.text <> "0" then

Good job