Reputation:
I have three Edit boxes, these are used to feed Parameters into a query for my database, which in return executes and returns the desired results. This all works, the problem I'm having is this :
if ((DayOfWeekSCH.Text) and (EndTimeSCH.Text) and (StartTimeSCH.Text)) <> '' then
DayOfWeekSCH
, EndTimeSCH
and StartTimeSCH
are all edit boxes, what I'm attempting to do, is make sure these boxes aren't empty before executing the code to execute the query. But I'm getting the E2015 Error
which I don't understand why I'm getting it.
EDIT: This is the full error code:
[dcc32 Error] PAvailableForm.pas(37): E2015 Operator not applicable to this operand type
Upvotes: 1
Views: 484
Reputation: 4878
E2015: Operator not applicable to this operand type
where <string> and <string>
does not make sense since and
is interpreted as a boolean or bitwise operator, depending on its operands: hence the error.
See Boolean Operators and Logical (Bitwise) Operators.
It seems you want to achieve something like this:
if DayOfWeekSCH.Text + EndTimeSCH.Text + StartTimeSCH.Text <> '' then
Anyway the above is a wrong way to perform a string comparison.
You might want to see this answer on how to check if a string is empty.
Related to the question, since an edit box, say a TEdit
, descends from TControl
, the GetTextLen
method can be used in order to check the text buffer size: if 0
the text is empty.
if (DayOfWeekSCH.GetTextLen > 0) and (EndTimeSCH.GetTextLen > 0) and (StartTimeSCH.GetTextLen > 0) then
Upvotes: 1