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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

elegant method to check if any of a set of strings are empty or not?

Status
Not open for further replies.

CADTenchy

Technical User
Dec 12, 2007
237
GB
I have a set of comboxes for the user to input or select some text.
At processing time it's OK for these comboboxes to be either empty or contain something, as long as they are all same state.
They either all are empty, or they all have some text.

I can access the comboboxes' text property by an array (thanks Aaron!), so I could run through each one in a for to loop and test with an if statement and a flag or two, or use a couple of enormous multi conditional if 's, but I was wondering is there is a smarter neater way?


Steve (Delphi 2007 & XP)
 
so I could run through each one in a for to loop and test with an if statement and a flag or two

That'd be the way I'd do it. Use a while loop, though, and break out of it if you find a condition contrary to your requirement (text if all empty or no text if all full).
 
Yes a loop using controls collection...
---
for i := 0 to ControlCount-1 do
if Controls is TComboBox then
if (Controls as TComboBox).Text <> / = '' then
---
Hope this helps,

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top