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

Bad Logic 2

Status
Not open for further replies.

lazytrucker

Programmer
Aug 4, 2004
39
GB
I am trying to create a piece of code which follows the logic of:

If ARRAY(0) TO ARRAY(i) = TRUE THEN

Where (i) is unkown.

I know this is bad syntax and I have a tempory solution but it's been annoying me that there must be a better way to do this.

Any Suggestions??

Cheers LazyTrucker
 

You could try this:
Code:
Dim sArrayCount
sArrayCount=0
Do
  '# some code here

sArrayCount = sArrayCount + 1
Loop While sArrayCount < uBound(strArray)

Or if you want to just loop through every thing in the array you could use for each method... like so..

Code:
For each strItem in strArray
'# strItem is the value in the array....
'# your code here..
Next


- Jason

www.sitesd.com
ASP WEB DEVELOPMENT
 
Hello lazytrucker,

Try this:
[tt] if eval(join(ax," and "))=true then[/tt]
where ax is the array with boolean entries.

regards - tsuji
 
Thanks for the tip tsuji worked first time. Could you briefly explain how it works as I dont really understand the functionallity??

Cheers LazyTrucker
 
lazytrucker,

With join using separator " and " (with a space in front and after) you get effective a literal string:
ax(0) and ax(1) and ...ax(n)
With eval() you evaluate the string and the result is true if and only if all ax(i) are true.

You can do " or " etc. for different purposes. But, you know, do not use eval() too generously.

- tsuji
 
Extra star from me, this is a very elegant solution, better then the one I was going to propose, in fact. Very nice,
-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
Help, the rampaging, spear-waving, rabid network gnomes are after me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top