I'd help you out, but I can tell your not including all the code because of this:
If r=True txt$=TextAreaText$(textarea) red=RequestedRed() green=RequestedGreen() blue=RequestedBlue() curtext=TextAreaCursor(textarea,1) If curtext<>0