Booleans

1. Senior Member
Join Date
Dec 1969
Posts
521

Booleans

Hi<BR><BR>I have avalues in array that are either true or false but when I loop through the array and the value is equal to true it still goes &#039;Else&#039; in the IF statement. Any ideas?<BR><BR>thecount=0<BR>Do<BR> theextrainfo = myArray(5, thecount)<BR> thecount = thecount + 1<BR>Loop Until theextrainfo = true OR thecount = Ubound(myArray ,2) <BR><BR><BR>If theextrainfo = True Then<BR> response.redirect "spec.asp?orderID=" & theorderID<BR>else<BR> response.redirect "thankyou.asp"<BR>end if<BR><BR>Thanks<BR><BR>Gary

2. Senior Member
Join Date
Dec 1969
Posts
206

RE: Try this:

If (Cbool(theextrainfo) = True) Then

3. Senior Member
Join Date
Dec 1969
Posts
7,686

RE: Booleans

Are you sure you don&#039;t just store "True" in the variable?<BR><BR>in that case you should do:<BR><BR>IF theextrainfo = "True" THEN<BR>

4. Senior Member
Join Date
Dec 1969
Posts
200

RE: Booleans

try something like this....may need some rework...:<BR><BR>thecount=0<BR>theextrainfo = myArray(5, thecount)<BR><BR>for thecount = lbound(theextrainfo) to ubound(theextrainfo)<BR>if theextrainfo = true then<BR> response.redirect "spec.asp?orderID=" & theorderID<BR>exit for<BR>end if<BR>next <BR><BR>if theextrainfo=false then<BR>response.redirect "thankyou.asp"<BR>end if<BR><BR>

5. Y3L
Junior Member
Join Date
Dec 1969
Posts
5

RE: Booleans

assuming vbscript:<BR><BR>you can try <BR><BR>...<BR>theextrainfo = CBool(myArray(5, thecount))<BR>...<BR><BR>if theextrainfo then <BR> ...<BR><BR>Does this help ?

6. Senior Member
Join Date
Dec 1969
Posts
11,247

I may be wrong but....

I thought you could do this.<BR>If theextrainfo Then<BR> response.redirect "spec.asp?orderID=" & theorderID<BR>else<BR> response.redirect "thankyou.asp"<BR>end if

7. Senior Member
Join Date
Dec 1969
Posts
11,334

Nope, you're right, and it's preferred

cause an if statement has to have a boolean expression.... saying <BR><BR>if something = true &#039;returns true<BR><BR>is kinda redundant.... <BR><BR>if something then &#039; seems easier to read, IMHO.<BR><BR>When I do code reviews of people at work, I always have them take out any explicit boolean checking (if boolVar = true) and have it done your way.

8. Senior Member
Join Date
Dec 1969
Posts
11,247

Thanks Ghost sometimes my mind

plays tricks on me.<BR>You dreeing up for halloween or going as yourself?

9. Senior Member
Join Date
Dec 1969
Posts
11,334

LOL... that seems like a loaded question

So you&#039;re saying I&#039;m ugly enough to go as myself? ;)<BR><BR>Nah, not dressing up tonight, nor today at work. My wife gets dressed up for her work though.<BR><BR>Nope, gonna take the kids around the block, and then "sort through their candy to ensure it&#039;s safe". Meanwhile, I can grab a private stash for myself :)

10. Senior Member
Join Date
Dec 1969
Posts
11,247

RE: LOL... that seems like a loaded question

Not ugly lol<BR>Yeah I used to do the same with candy but kids too old now. a year or two and it&#039;ll be the grandkids I &#039;steal&#039; from!

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•