delphi - What is the best practice for checking if the edit not empty -
i'm wondering best practice validate edit not empty
if edt1.text <> '' //dosomething else showmessage('check 1'); if edt1.text = '' showmessage('check 2') else //dosomething
reading text property loads edit's current content memory temporary string . if want check if edit empty, there more efficient way that:
if edt1.gettextlen > 0 // not empty else // empty of course, length > 0 if edit contains characters @ all, if whitespace. if need ignore leading/trailing whitespace, have no selection retrieve total text , trim it:
if trim(edt1.text) <> '' // not empty else // empty delphi
No comments:
Post a Comment