Need help writing to DAC

Unless you post ALL the code it is hard to come to any conclusion.
Also don't use the quote icon for code use the # icon next to it.