Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Incompatible types?

Status
Not open for further replies.

Cogz

Programmer
Joined
Jan 16, 2003
Messages
7
Location
CA
In the line:

lstbx is a listbox.

---
if lstbx1.ItemIndex + 1 > lstbx1.Count and lstbx1.Count > 0 then
---

I get "incompatible types" error.

So now I would either have to use an object property with a constant value of 0, or waste memory by creating variables that hold the needed lstbx1 properties.

Am I missing something or is there a better way?
 
Hi there,

What you're missing are parentheses. Try this:

if (lstbx1.ItemIndex + 1 > lstbx1.Count) and (lstbx1.Count > 0) then

This works because when the compiler looks at this line, it simply reads from left to right and compares the boolean result of "lstbx1.ItemIndex + 1 > lstbx1.Count" which will equal True, and then tries to evaluate the expression of "True and lstbx1.Count".

The parenthesis force the logic to be evaluated the way you're expecting. Any and/or expression should use parentheses in this way.
 
Great, it works.


tnx Griffyn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top