• Welcome to Valhalla Legends Archive.
 

Need Help

Started by OuTLawZGoSu, August 01, 2003, 08:19 PM

Previous topic - Next topic

Adron

Normally if two alternatives do the same thing, I'd pick the shorter one. How come you're not using


If chkwhisper.Value = 0 Then
whisper = True
Else
whisper = False
End If


or


whisper = chkwhisper.Value = 0


or


whisper = Not chkwhisper.Value


?

Avenge

yeah I would rather use a short string than a million If statements, but that is just me..

Camel

Quote from: Adron on August 12, 2003, 11:34 AMwhisper = Not chkwhisper.Value
Not that it matters in this case, but it would be prudent to use Not CBool(chkWhisper.Value) as the VB Not function is bitwise not, not boolean not. Additionally, if chkwhisper.value was set to 2 (grayed), whisper would be set to -3 (or True if it's boolean) which may be undesired, even though I cant think of any reason you would want to do that do said checkbox.

Anyways, it's just something to keep in mind while using boolean Not/And/Or/Xor.

?not 0; not 1; not 2
-1 -2 -3

?cbool(not 0); cbool(not 1); cbool(not 2)
TrueTrueTrue

?not cbool(0); not cbool(1); not cbool(2)
TrueFalseFalse

Adron

Good point, I didn't think of that. It shall be =0 then, and that's equally short, so it's a perfectly good choice!

Camel

Quote from: Adron on August 12, 2003, 11:34 AMwhisper = chkwhisper.Value = 0

Once again, not that it matters, but I prefer: whisper = (chkwhisper.Value = 0) as VB has no == operator. In c, the same code would set both the values of whisper and chkwhisper.Value to zero, but in VB the = operator is used for both value assignment and comparison.

Grok

Wow!  How can so many people be so wrong in so short a time in so many different ways?  My turn to be wrong.

A checkbox is tristate.  It has values 0, 1, 2.  Since 0 is unchecked, 1 is checked, and 2 is grayed, we presume 2-grayed to mean uncheckable, and thus not checked.  So 0 and 2 both will mean we don't whisper.  Only 1 means checked/whisper, so we have to check for that value.


whisper = (chkWhisper.Value = 1)
Send Iif(whisper,"/w " & username,"") & " ---- OuTLawZ BoT"

Camel

Quote from: Grok on August 12, 2003, 06:46 PMA checkbox is tristate.  It has values 0, 1, 2.  Since 0 is unchecked, 1 is checked, and 2 is grayed, we presume 2-grayed to mean uncheckable, and thus not checked.  So 0 and 2 both will mean we don't whisper.  Only 1 means checked/whisper, so we have to check for that value.

IIRC, 2 just means grayed. It doesn't specify checked or not -- it can be either grayed checked or grayed unchecked and either way the state will be 2, based on the last value before it was set to 2.

Grok

Quote from: Camel on August 12, 2003, 07:30 PM
Quote from: Grok on August 12, 2003, 06:46 PMA checkbox is tristate.  It has values 0, 1, 2.  Since 0 is unchecked, 1 is checked, and 2 is grayed, we presume 2-grayed to mean uncheckable, and thus not checked.  So 0 and 2 both will mean we don't whisper.  Only 1 means checked/whisper, so we have to check for that value.

IIRC, 2 just means grayed. It doesn't specify checked or not -- it can be either grayed checked or grayed unchecked and either way the state will be 2, based on the last value before it was set to 2.

If you can make it unchecked+grayed, you have a different checkbox than I do.  Mine is always checked+grayed when the value is 2.  The value cannot be "2, based on the last value before 2" because that doesn't even make sense.  There are not multiple values of 2.  It is a discrete value.

Tossing aside all that, the common-sense approach is this is a "Check me to lock whisper" box, most likely.  This means the user will be checking and unchecking it when the bot is online, and the only time it will be grayed is when the user is offline, making whispers nonsensical.

CrAz3D

chkWhisper.value = vbChecked works jsut aswell
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

Adron

Quote from: CrAz3D on August 12, 2003, 08:24 PM
chkWhisper.value = vbChecked works jsut aswell

But now you've inverted the sense from the post I replied to. That post set whisper to True if and only if the box was unchecked! You're doing the opposite.

Grok

Quote from: Adron on August 13, 2003, 03:41 AM
Quote from: CrAz3D on August 12, 2003, 08:24 PM
chkWhisper.value = vbChecked works jsut aswell

But now you've inverted the sense from the post I replied to. That post set whisper to True if and only if the box was unchecked! You're doing the opposite.

Yes I thought that was strange.  If you follow the replies back to the original, it was only whispering when the box was checked.   Someone messed it up along the way.  Dr.Jay, I think.

tA-Kane

#26
Not that it really matters, but in REALbasic, you can set both the checked and the greyed properties of a checkbox, using .value and .enabled, respectively.

This is quite useful if you want to disable a checkbox, but still show what its value was to the user, or even save its value, so that it's automagically restored when the checkbox gets ungreyed.
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com

Adron

Quote from: Grok on August 13, 2003, 06:18 AM

Yes I thought that was strange.  If you follow the replies back to the original, it was only whispering when the box was checked.   Someone messed it up along the way.  Dr.Jay, I think.

Yes, that was another reason I picked his post to reply to. Much more interesting that way ;)

Camel

Quote from: tA-Kane on August 13, 2003, 07:34 AM
Not that it really matters, but in REALbasic, you can set both the checked and the greyed properties of a checkbox, using .value and .enabled, respectively.

This is quite useful if you want to disable a checkbox, but still show what its value was to the user, or even save its value, so that it's automagically restored when the checkbox gets ungreyed.

Same thing in vb. The .enabled property when set to false disables the checkbox, meaning you cannot check it. The .value property when set to 2 just turns it gray, but it can still be checked. IIRC, both methods will show the previous state of the checkbox (checked or unchecked).

tA-Kane

#29
Ahh, my bad.

So if you set .value to 2, how do you know if it was checked or not?
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com

|