« first day (2015 days earlier)      last day (170 days later) » 
00:00 - 19:0019:00 - 00:00

7:00 PM
hm. Technically, that's just VBA's implicit voodoo conversion
no it's weirder than that
Sub test()
    Dim a As Boolean
    a = 2

    Dim b As Boolean
    b = CBool(2)

    Debug.Print CInt(a), a, Not a
    Debug.Print CInt(b), b, Not b
End Sub
-1            True          False
-1            True          False
I do not see the problem.
there's no problem in that code here
A: VBA: Why would the Not operator stop working?

Cindy MeisterI believe the explanation has to do with how older programming languages (WordBasic and early VBA) stored the integer values of True and False. In those days, True = -1 and False = 0. Newer programming languages still use 0 for False, but 1 for True. The majority of Word's Boolean type properti...

but it contradicts how Word does it
That is unsettling.
somehow CInt(X) returns 2
@IvenBach very
7:03 PM
Along the lines of shaking a fundamental belief about Boolean logic unsettling.
Still not getting it.
the problem would manifest itself if you played fast'n'loose with the data type but in this case, it seems to be expected that Not x = False
X = True then X = Not X should produce a value of what?
literally, Debug.Print Cint(X) (with X As Boolean) outputs 2 and that is not supposed to happen
Ok, i see hte problem now
Sub test()
    Dim a As Boolean
    a = 2

    Dim b As Boolean
    b = CBool(2)

    Dim c As Boolean
    Dim d As Boolean

    c = Not a
    d = Not d

    Debug.Print CInt(a), a, Not a, c
    Debug.Print CInt(b), b, Not b, d
End Sub
-1            True          False         False
-1            True          False         True
I don't
that doesn't repro
I can't repro it outside of Word
7:07 PM
that was from Excel
yeah, and nothing unexpected in the output
did you intend d = Not d?
that was my mistake
should be d = Not b
and corrected, then it behaves as expected
so... back to my original position --- not seeing the problem, exactly.
but make a table in Word and then try the OP's code
somehow, Boolean is retaining its underlying value of 1 instead of being stomped to -1 like everywhere else
here's a better demo, I think.
Private Type t1
    b As Boolean
End Type

Private Type t2
    i As Integer
End Type

Public Sub testbits()
    Dim b As t1
    Dim i As t2
    Dim i2 As t2

    i.i = 256
    LSet b = i

    LSet i2 = b

    Debug.Print i.i, b.b, i2.i
End Sub
 256          True           256
This seems a good case as to why you should not If Not <condition> Then but rather If <condition> = False Then
7:13 PM
using OP's code, I had CInt(X) return 2. With X declared As Boolean, my (previous?) understanding of VBA was that this would be impossible and CInt(X) could only ever be 0 or -1
But see, if I LSet, I'm circumventing VB's safeguards.
@this if we can't trust that Boolean is 0 or -1, then any Not, Or, And, XOr logic goes out the window
We can observe similar problems with calling API that ordinarily returns 1 for result.
Well, if you define it As Boolean, then that is not a problem. The safeguard makes sure it's correct
it's only when you directly write to the memory then strange thing can happen
Realistically, that is no different from C/C++ which only uses 1 as a convention
How are the circumventing the safeguards with the given code?
but in all of its tests, it's always if(<condition> = 0) {failed();} else {succeeded();} (or perhaps if(!<condition>) {succeeded();} else {failed();})
Word's dumb?
7:17 PM
I agree that words are dumb. Motion to revert to grunting and pointing has passed!
uh, Word, not words. ;-)
#Words ;p
Anyway: That's why I usually advocate for writing conditions in either If <condition> Then or If <condition> = False Then; anything else is just a time bomb
it also bears pointing out that Not, And, and Or are bitwise operators, not logical operators, even though we pretend it could be used like logical ones.
and because we don't have an Option Strict, it's too easy to accidentally end up with a implicit Variant result from a <condition>; so for that reason, I can't even trust If someFunctionThatReturnsABoolean() = True Then
I agree with your #BeltsAndSuspenders view the more I learn. If foo = (True | False) Then just feels wrong to me.
If foo = True Then is wrong, indeed but If foo = False Then is correct.
If Not foo Then is wrong.
Implicitly all conditions are basically If <condition> <> False Then
so if you put it in a table, you can see why If Not foo Then could end up wrong
7:26 PM
@IvenBach not only that, I've been telling everyone it's redundant, for years!
same with If foo = True Then
In short, you want to ensure that all your condition can only yield a falsy result because falsy result is the only one that's constant everywhere.... Everyone (well, except JS...) expect a falsy result to be one that's equal to 0.
But not everyone agrees on what constitutes a truthy result -- some say 1, others say -1, yet other say true, etc. etc. Confusion abounds.
@MathieuGuindon Winter Christmas is coming. You can gift everyone you ever told to just do If foo Then an apology. Check that list not -3 times though.
uh? No.
If foo Then is correct.
It's If foo = True Then that's not right.
But the converse does not hold!
e.g. If Not foo Then is wrong; you want If foo = False Then
My take on this is simply Only use things with explicit boolean type in conditionals.
Except in languages like Pyhton that really expect you to put just anything into conditionals and boolean operators.
It is even in the style guide.
the issue, though is that you can't guarantee that you won't get hit with an implicit conversion when evaluating an expression. The above works in all cases, explicit booleans or not.
and I prefer a coding style that is always correct even in face of absurdity.
7:35 PM
I think the programming language should really take care to always convert to boolean before applying logical operators.
The stupid thing in VBA is that they overloaded the logical and bitwise operators to do both.
Other languages have them separated.
IINM, you have the same problem in C or C++.
and VBA probably builds on atop of C++
You will not really see a C++ coder normally using expression like if(<condition>==true) for that reason.
Huh, the logical and bitwise operators in C and C++ are distinct.
in C, that is moot since there is no such thing as boolean data type. I am bit fuzzy how it's done in C++.
C++ has an explicit bool data type.
given that VBA has no distinct logical operators, you'd be looking at writing If Not CBool(<condition>) Then to get the same behavior as C/C++'s if(!<condition>)
If <condition> = False Then has the same meaning & behavior but does with less words.
A small revision:
Public Sub testbits()
    Dim b As t1
    Dim i As t2
    Dim i2 As t2

    i.i = 256
    LSet b = i

    LSet i2 = b

    Debug.Print i.i, b.b, CInt(b.b), i2.i
End Sub
that does proves that the Boolean can store a value other than True/False, providing that you don't use VBA's usual way of assigning values.
7:48 PM
and for the last ~25 years I've been thinking the output of CInt(anyBoolean) could only ever be 0 or -1
I do not see the boolean here.
Well, remember, the problem is that everything's a 0 or 1.
If you write to some random memory location, you will get strange undefined behavior.
Private Type t1
    b As Boolean
End Type

Private Type t2
    i As Integer
End Type
@M.Doerner ^ the types involved (assuming they haven't changed)
I assume that whenever you assign a value to a Boolean, or read from it, VBA obviously is smart enough to coerce it for you.
but CInt() is too naive for that.
and, that's what you get for ass-u-me-ing...
7:51 PM
what surprises me is that the coercion isn't happening at write-time
it should.
"it should happen" or "it should surprise him"?
Ok - X = Selection.Cells(1).FitText <- coerecion doesn't happen.
i have no idea what it's doing there.
Public Function IAmDumb() As Long
    IAmDumb = 1
End Function
Public Sub test2()
    Dim b As Boolean

    b = IAmDumb

    Debug.Print Not b, Not 1
End Sub
that doesn't repro.
right. looks like user code can't do it (other than with LSet)
> True if Microsoft Word visually reduces the size of text typed into a cell so that it fits within the column width. Read/write Boolean.
7:58 PM
so it returns a Boolean
yes, but one with 1 for true
therefore, if Word API sets it to 1.... well, that doesn't get coereced
let's prove that.
feel free to answer :)
Public Sub test3()
    Dim b As Boolean
    Dim b1 As t1
    Dim i1 As t2

    i1.i = 1
    LSet b1 = i1

    b = b1.b

    Debug.Print Not b
End Sub
That returns True
so, assignment of Boolean to another Boolean is not checked.
had it been a Long or Integer, then it would have gotten coerced by VBA
8:00 PM
now I wonder how many times in 25 years this bug was "discovered"
I've ran into it before. That's why I'm dogmatic about always writing conditions as If Foo Then and If Foo = False Then, never any other varieties.
I've written "If Foo = False Then is redundant, do If Not Foo Then instead" countless times all over CR & SO, for 7 years :(
at one point I thought as long it's converted into boolean, but I ran into another case where that is a dangerous assumption due to VBA's implicit here-let-me-manhandle-this-for-you-because-we-know-you-are-a-dumb-schmuck-and-I-know-better conversion.
That particular one, yes, should be apologized for. :)
but if it's If Foo Then, then no worries.
1 hour ago, by this
I need to remind myself that in the end, everything's a one or a zero.
there is no logic
(Jedi mind-trick hand motion)
wait, I think I saw a 2.
8:04 PM
it's all bitwise. there's no logic. DONT LOOK FOR ANY LOGIC
poofs into a Force-ghost
dang I need caffeine
sounds like a perfect inspection candidate
A: VBA: Why would the Not operator stop working?

thisTo add on to Cindy's excellent answer, I want to point out that while VBA normally has safeguards to coerce the values when assigning to a Boolean data type, this can be circumvented. Basically, if you write a random value to a memory address that's not yours, then you should expected undefined b...

#Protip: Don't twiddle the bits.
8:27 PM
So, if I understand this correctly, the problem is that somebody at MS goofed up and forgot to send the return value generated in C++ through oleaut or similar before returning it as Boolean in VBA.
basically, yeah
8:43 PM
> Version
OS: Microsoft Windows NT 10.0.18362.0, x64
Host Product: Microsoft Office 2013 x86
Host Version: 15.0.5023.1000
Host Executable: EXCEL.EXE

This is an intermittent issue. When using the hotkey `Ctrl+T` to open a new browser tab, which is also the same as Find Symbol, RD is latching onto it. RD displays the Find Symbol dialog even though the VBA IDE isn't the active window.

**To Reproduce**
Steps to reproduce the behavior:
1. Have VBA IDE open in
I think that's a known issue?
fixed, even. multiple times.
Oh? I thought it wasn't.
since it was a heisenbug
It's not fixed on my machine.
We building RD with 2017 still or 2019?
still 2017
will be 2017 until 2.5.0 is released
8:54 PM
speaking of which... what's stopping us form releasing 2.5?
said the guy who hasn't been contributing
we're waiting for some CS translations. other than that, ..I'd like the inspection results toolwindow scrollbars to behave and not wreck the bottom panel layout, but that's rather minor
How about just moving the scroll viewer just around the grouping grid and pushing the change?
that should work, I think
first time after opening a workbook a boolean function fails to pass "true". not sure what to do to fix that; after that first use, everything runs smooth
@Cyril what's the _Open handler doing?
9:06 PM
i take it i need to instantiate the functions on load?
IDK, was a stab in the dark, I've no idea what code you've got! :)
no worries; thought you had some like "i have that problem all the time" moments
#TIL a WPF keybinding can bind the WinKey as a modifier
fuck yeah, was typiing to you exactly what i was intending to do and solved it
9:17 PM
i made an array of my boolean variable states and generated BEFORE i populated the true scenarios
gotta love it
@MathieuGuindon I hope it doesn't let you bind it standalone without modifier. That would make for a evil application.
Good evening!
@MathieuGuindon Explain how someone made a power function thats insanely faster than the builtin one, and, is entirely bitwise?
haven't done bit math in 20 years, ..I'm a bit rusty
lol that's horrible
@MathieuGuindon Quick. What's derivative of x^(y^2+3*x)dx * cos(y^2 * 3x)dy???
9:30 PM
@BigBen I know, I know.. I'm here all week :)
Oh wait that's not bit math? :derp:
@IvenBach 42
can a select case (switch) also function as a flowdown? first case met, use that, then proceed to check each case?
nope. VBA doesn't do fallthrough.
copy; guess those will become if-statements per case. thanks!
9:37 PM
IIRC you can use Select Case to short circuit.
VBA's lack of overloading irks me a bit.
yeah, you can, but that's not what Cyril is after.
@IvenBach yes but that's not what the question is :)
@IvenBach and once you get a language with overloads, you want overloads that return a different type, and you're back at square one
but yeah, it gets annoying :)
VBA with method overloading would simplify naming.
9:40 PM
case sensitivity would simplify naming too!
~.~ yes it would.
but, I hear ya
git diff is killing me because of that.
@MathieuGuindon you should talk to Jeff Atwood.
I should!
9:41 PM
git: Hey. All these changes happened.
Iven: That's cause they casing changed. I'm not concerned.
git: Hey. All these changes happened.
Iven: I know *casing* changed.
git: Hey. All these changes happened.
Iven: FML...
git ain't that bright.
> That boy sure is dumb.
alright, that's fixed... 169 logic gates; flowthrough/flowdown would have been amazing lol
idk if any other languages use those terms.
it's always been "fall through"
9:48 PM
ahh, i misquoted you on "flowthrough"
and I suspect most modern languages doesn't let you do that, either.
i had used it as flowdown, but that's related to fluid dynamics which is the closest memory i had of that function
Fall throughs were one good source of bugs
<-- got learnt
ok, one of these days i'll get back to reading mat's blog about class modules; i feel like that would have helped me on this, but i'm a glutton for punishment...
off to clean the house before i have to get kids. night folks!
10:04 PM
Duck checking that git diff HEAD..FooBranch permits me to check the currently checked out head against a local branch named FooBranch.
if im encountering a situation where my interface names are sounding (i think) like an inheritance structure is that a problem?
if that isnt enough for an answer i can detail lol
You have the names and code?
code is a mess
names yes
one instance is something like IFormControl and IFormButtonControl
im not even sure if what im doing is right, which is why i asked
May need to wait for a bigger duck. I rarely use forms.
Just from IFormControl that comes off as a code smell (something that feels odd).
Exactly what do you intend to achieve?
10:16 PM
lol I just scored an "announcer" badge on meta.se and kept wondering why/when I shared a link to that. then I saw the comments..
Send them to gimmetehcodez.com! (link points to Mad Scientist's answer ;) — Mathieu Guindon May 1 '14 at 19:27
took 5.5 years, but I got 25 clicks on that link lol
@this basically im trying to make my userforms as easy to edit/maintain as possible
when requirements change
See, I think that's wrong level.
and have the interactivity behavior more aligned with modern windows
Because a form is already an interface
10:18 PM
ditto for controls or anything that's from an external library, actually
any class is already an interface
in fact, everything in COM is interfaces.
What Mat said.
You want something more like....
that doesn't mean we shouldn't have interfaces in VBA though
10:19 PM
IInventoryDataEntry, or ISaleTransactionDataEntry or something....
that seems rather specific, compared to IFormControl, which looks nicely abstract
e.g. represent an action you need to perform and encapuslate that action.
But what will you do with a IFormControl, though?
thinking dynamic controls are involved?
what exactly do you mean by dynamic
like add/remove at runtime?
created at run-time
10:20 PM
yeah that is one reason
that is actually
what caused me to use my first class module for a project
See, the name matters. If it was IRuntimeControl or IDynamicControl, that would be more clear, I think.
but its not necessarily for that
IFormControl doesn't say much.
its just meant to be any control on the form
10:22 PM
Which brings us back to the original question - why do you even need an abstraction over the controls themselves? They are already an interface.
If you want, you can use MSForm.Control to be more generic (right?)
well you know how the controls in userforms are very "retro"
Use Access forms, then. :p
some of them you can rescue with formatting, others you cant
So your'e writing your own UI framework?
10:23 PM
or at least a theme thing.
so I guess that also means a IFormControl could be actually several controls.
to provide the look you want.
OK, so, why not IThemedControl?
its not themed necessarily either
10:24 PM
the point being, you do want to have your names say something about what it does
so if I'm coming along I can see immediately why you're programming against a IFancyPantControl and not MSForms.Checkbox
Now.... I assume that you are trying to do multiple inheritance.
i just have it at IFormControl because not all of the controls are fancy
i thought you cant do inheritance in vba?
like the textbox is the actual textbox
then I didn't understand your original question:
10:27 PM
14 mins ago, by the VBE - it's right for me
if im encountering a situation where my interface names are sounding (i think) like an inheritance structure is that a problem?
i said sounding because
It sounds to me you're saying thee's multiple level of inheritance, like datepicker -> data entry control -> control or something like that.
IFormControl and IFormButtonControl
Ok, that's what I thought. there are multiple interfaces
oh multiple interfaces?
10:28 PM
so therefore a FormButton would need to implement both IFormControl and IformButtonControl
yeah that is how i have it structured
but i wasnt sure if that was correct
that is OK.
You may want to consider providing a property to aid in casting, though.
as an example have the IFormButtonControl implement a Public Property Get Control As IFormControl
then the syntax becomes a bit nicer -- myButton.Control.<some method on IFormControl interface>
oh wait you can do that?
that seems like it might be helpful in some cases
yeah but just so we're clear --- the FormButton still has to have both Implements IFormButtonControl and Implements IFormControl
10:31 PM
and implement both interfaces in its code module but yes, you can certainly add a Control As IFormControl to a "more derived" interfaces like IFormButtonControl
it returns itself in the property
Hello from AWS!
I am working on becoming serverless!
very helpful insight ty
10:32 PM
that way, you wouldn't have to do a Dim ib As IFormButtonControl then Dim ic As IformControl
and have them assigned to same object.
yeah i was running into that problem too
when i needed to return something as one interface or the other
yes, the above works for going from more derived to less derived
that isnt a precise way of saying it, but basically i had to make what seemed like extraneous declarations
I think as long you consistently always go from most derived to less derived, you will be fine.
okay so clarify the derived thing
IFormButtonControl is more derived
and IFormControl is less?
10:34 PM
meaning, you start with the FormButton class itself, return a IFormButtonControl which can be then used to return a IFormControl where you need it.
okay got it
mostly at least
enough to start trying to apply it to what was getting me stuck
thank you :)
good luck!
no promises i wont come back in a bit with more questions of course :3
10:51 PM
:derp: git remote add foo "\\localnetwork\...\.git" caused me far too long to catch that I needed to escape the '\` to accurately map the url.
:glare: escaping stuff escapes me how to do it properly.
@Duga got a hat yet? @SimonForsberg
(and the yearly notification count screenshot!)
@MathieuGuindon Even I don't have a hat yet.
Is there any easy hat that she can get?
"Warm Welcome", I suppose (it's last year's hats, so, same secret ones)
@MathieuGuindon How to get it?
Q: Winter Bash 2018 Hat list

DavidHere we go again, the Winter Bash is here and the hats are listed below. The list has the same format as always, there are only two answers: one for the secret hats, and one for the regular hats. The secret hat list will be updated as we learn them. Only edit the secret hat answer with definiti...

You could vote on an old post too
11:09 PM
#TIL Left click to hold and drag a window. While dragging, wiggle the window back and forth. It'll minimize all the other windows but the one you're dragging. Release the mouse button and now that's the only window not minimized. If you don't want to actually minimize before letting go of the left click button press Esc to cancel the minimize.
11:33 PM
Win key plus shift plus m will replace all minimized windows... or at least that was in win7
I have a sensitive mouse and accidentally wiggle-minimize often
11:50 PM
Hm, anyone else just got like a dozen+ announcer/booster badges? looks like a badge recalc task is under way
00:00 - 19:0019:00 - 00:00

« first day (2015 days earlier)      last day (170 days later) »