« first day (1418 days earlier)      last day (1762 days later) » 

4:01 PM
> For reference, by section 2.1 of the VBA specification, a date is an 8-byte IEEE 7541985 floating point number, i.e. a Double, that is interpreted as the (fractional) number of days since(positive)/before(negative) midnight of December 30, 1899.
 
Apr 6 at 20:01, by puzzlepiece87
@MathieuGuindon Hopefully this cheers you up - another long-term thank you from me for something you discussed long ago that eventually got crossed off my todo list: Thank you for mentioning that you do a lot of data reads from other Excel files via ADO.
@MathieuGuindon Another long-term thank you - I'm implementing your Userform tutorial to make all my existing programs that use them better.
 
> Seems this is a problem we've already solved in Rubberduck.Parsing.Preprocessing, which evaluates expressions in precompiler directives: github.com/rubberduck-vba/Rubberduck/blob/next/…
 
This was another thing that was on my todo list of things to review that you told me about.
 
@puzzlepiece87 thanks! ...geez, I never got around to put up that demo I promised
@Duga I think we really need to move the Preprocessing stuff into an Expressions namespace or something - we need to reuse that code somehow.
 
@Duga Nice! but this seems to put the date in .NET's Date? Does it compare to the Double?
Agreed RE: move. Sic Vogel. ;-)
 
4:09 PM
@this as long as it correctly parses date literals, then TBH I'd much rather do the date ops with .NET's DateTime and TimeSpan types :)
 
It'll be accurate, yes but not sure if it'll match with VBA which uses them like double.
we are supposed to think like VBA does.
 
@MathieuGuindon You sure like tapping the insect nests with branches.
 
@this yeah... we're literally entering interpreter territory here :)
@IvenBach one does not simply call my stuff "anti-pattern" and walk away without a fight!
 
@MathieuGuindon a flask or two plus few blows to the head may be required.
 
Hadn't noticed it was put on hold.
 
4:12 PM
well, I sent it to the close queue when I voted to close
should have been closed must faster than that :/
@IvenBach and yes. next RD News post is exactly about this, and already scheduled to publish at 8PM tonight.
 
I was near giddy seeing your post about factories. You'll be getting some question from me a bit later today.
 
another one is coming up about the builder pattern
 
I do have one, @MathieuGuindon - if for instance, you have 100 classes using this pattern, don't you end up eating up lot of memory for all those predclared instances?
 
I feel I'm at a point where I can understand and appreciate some of the patterns now.
 
@this I write VBA like objects are free, until that's a problem. never has been.
it's just a pointer, so uhm, that's a huge 4 bytes per object?
I can live with 400 bytes of pointers for all these predeclared id's :)
 
4:17 PM
well, it's not just a pointer
I assume the class has to be put into the memory
so it's defintiely more than just 4 bytes.
 
yeah, the UDT needs to be allocated for the default instance as well, so that's calculatable
 
I also do not know how it handles instances -- are each instance their own deep copy of the template? Or do they only keep a copy of the module level fields and share the functions?
 
I've always presumed a predeclared ID was just an ID that was, well, predeclared
 
I see it as simply another instance.
 
IOW doesn't cost more and doesn't behave any differently than any other instance
yeah that
 
4:20 PM
no different than say, Public foo As SomeClass
 
^
except it's Public SomeClass As SomeClass :)
 
but with the factory method, we're basically instantiating 100 classes at the first use of each class, then instantiating a 2nd object that we actually use
yeah
 
you could always Load and Unload them manually if that gets you nervous..
 
you can load a class module?
I thought that was UF only
 
my understanding is that it works with anything with a default instance
 
4:22 PM
hmm. IDK. I will give that a try.
 
why implement a set of reserved keywords to deal with Object, and then restrict it to one specific subtype?
oh, hello run-time error 361
 
yeah
that's why I thought it was UF only
I thought I remembered trying it before.
RE: object parameter -- cos we gonna be loose and friendly with everyone.
 
hmm well that does change things a bit
 
you know how VBA love dem variant arguments.
so it's more accurate to say that predeclaredid is more akin to Public SomeClass As New SomeClass
 
it's actually Object As Object
yeah
 
4:26 PM
I can Set SomeClass = Nothing
but that just resets the preclaredid. I assume it's still there in memory.
Which is why I wondered about how instance are created; whether they only keep their private copy of the fields, or if they are a full deep copy.
If former, then pssh, going to be a long while before memory consumption becomes a problem.
If latter. :\
 
> You tried to load or unload an object that isn't a loadable object
so apparently the type must implement some obscure ILoadableWhatever interface
 
Deck check: Deep copy = everything is copied vs Shallow = pointer is copied (they both point to same thing).
 
pretty sure the fields are private copies
 
have to be by definition.
it's the procedures part i'm not 100% sure about.
 
each instance gets its own vtable, no?
 
4:30 PM
@IvenBach yes but mind I'm talking a bit loosely here.
wait, shallow copy means you get a new copy that contains only the same data for the public interface. Deep copy means both public and private data are the same.
in both cases, original Is copy should be false since they aren't the same object instances.
 
Public Property Get IsDefaultInstance() As Boolean
    IsDefaultInstance = Me Is Class1 ' where Class1 is the default instance
End Property
 
@MathieuGuindon seems logical. And I'd hope that the vtable points to the same set of functions defined by the template.
 
that, I wouldn't know
 
that does implies that for a bigger class, the v-table is bigger, and therefore each instance takes more memory.
 
learned about vtables' existence in this chatroom
 
4:34 PM
yeah, you have to be a C++ guy to even know about them.
VB people be all "wut"
 
heck, C# doesn't show it. You have to dig pretty hard to see it.
 
(mind you that's a good thing. We really shouldn't be playing with pointers. They're more dangerous than matches)
 
unsafe is one of the most accurately named keywords ever invented
#define herebedragons = unsafe
 
4:37 PM
hmm. should make Visual studio play eerie music and saying "Abandon all hope ye who enter here" whenever the unsafe comes in the window.
and see, that's another thing C# did right. No macros.
 
@this Then I didn't understand shallow vs deep copying...
 
@this meh. it's part of the programming paradigms lecture for CS at my Uni
@this "Soi che vos entrata"
 
huzzah - serialization of all the formats worked
 
@IvenBach shallow is basically just this:
Dim original As thing
Dim copy As thing

Set original = New thing

original.property1 = 1
original.property2 = "abc"
original.property3 = #1/1/100#

copy.property1 = original.property1
copy.property2 = original.property2
copy.property3 = original.property3

Debug.Print copy Is Original 'False
Debug.Print copy.property1 = original.property1 'True
Debug.Print copy.property2 = original.property2 'True
Debug.Print copy.property3 = original.property3 'True
 
so, now I need to store 6 arrays in the .dat file. IIUC, some of them can be of arbitrary size (heck, I don't even know what "Format17" is!)
 
4:48 PM
But w/ deep copy, you're not just setting public-facing properties. You are setting the private properties which you normally don't access.
it's not documented, @mansellan?
 
@this not that I could find
 
@this surprised?
 
given that they didn't even bother to register the format with a meaningful name, I guess not
duck check - I don't really want to go overboard in designing the .dat file, but I need to be able to split it back down to 6 byte arrays. so I think I'll just store a sizeof(segment) at the first 4 bytes of each segment. That should be ok right?
<aside> it's almost like MS circa 1997 didn't want people loading in custom icons </aside>
 
if it works...
 
coolio :-)
 
4:59 PM
@this I'll try to remember this.
I also read limbioliong.wordpress.com/2011/10/23/… that you linked to but I'm not groking hardly any of it. I'll have to come back to it.
 
@Vogel612 good for your uni. I've read reports where lot of places teach kids only on Java, thinking that pointers are too hard and must be hidden away or nobody'd sign up for the CS.
 
well we maybe shouldn't teach them about the difference in power between for-computability and while-computability then?
or what a Von-Neumann-Machine is
or how a CPU works
 
@MathieuGuindon I really shouldn't. I was more thinking that it might have been an obscure format that's no longer in use or something like that.
 
haven't seen a .dat in quite a while :)
 
@IvenBach In VBA, it's not really possible to do a deep copy because you can't brute-force your way into private fields as you can in .NET with Reflection
@Vogel612 IKR!
 
5:03 PM
let's not start to get ranty
 
puts away his soapbox
 
@this My lack of C# usage is preventing me from "getting" the concept fully. Once I do use it with regularity I'm sure it'll become apparent.
 
but for illustration, imagine the thing class had a Private secret As string as a module-level variable.
in the shallow copy, the original's secret wouldn't be copied to the copy
and of course you can't copy1.secret = original.secret
 
The default value vbNullstring would be its value, that is until something sets it from within the variable class.
 
let's pretend the original has topSecret and copy has vbNullString
so to get the deep copying, you would need to serialize the original
e.g. Public Function Serialize() As String : 'Make XML Of This Class : End Function
 
5:08 PM
serialize = "store externally for reconstitution at some point?" In-Laymans: it lets you remake the object by writing it's contents out.
 
darn. I have a knack of being late to the interesting discussions
 
Which discussions are those?
 
then you can have this:
Public Sub Deserialize(XMLData As String)
  Dim xml As someXMLThingy
  xml.Parse(XMLData)
  Me.secret = xml("secret")
  Me.property1 = xml('property1")
  Me.property2 = xml('property2")
  Me.property3 = xml('property3")
End Sub
 
well, anything in-depth tends to get my attention
2
btw, setting a predeclared instance to Nothing, is indeed effective at releasing the object. Only at next access does the object get re-created
 
note that you can now write to the secret and thus copy is now identical to original in all aspects, including the private fields except that copy Is original is still false, of course.
 
5:11 PM
@this 85%+ sure I conceptually get what his is doing.
 
@WaynePhillipsEA Hmm. So a Public Something As New Something would never actually release the object? I figured it behaved the same way.
 
it behaves exactly the same, at the implementation level
 
k that's kinda of what I expected.
and the memory footprint? Any insight to that?
 
copy Is original is false because the Is operator is checking the memory location. They are now two separate things in memory.
 
yeah, Iven
 
5:13 PM
every time you read the variable (pointer), it first checks if it is Nothing, and if it is Nothin, instantiates it.
 
so no different from the self-healing object pattern, then....
 
procedures are a one off cost, as are vtables
 
so I'm not wasting any extra cycles. Cool.
 
@IvenBach not when the members are accessed, but when the variable content itself is read
 
@WaynePhillipsEA Dim foo as new bar: set foo = nothing: debug.print foo.duk leads to instantiation of the variable any time one of its members is accessed?
 
5:14 PM
RE: memory cost -- Ok, that's very good to know. so it's really the module-level fields that that we need to consider for memory consumption.
@IvenBach a easy way to see this is to add a breakpoint to the Class_Initialize event
and observe whenever it gets fired.
it'll get fired on first access but not on subsequent access at least not until it's set to nothing
 
Checking that right now...
 
@this exactly, and you can think of a class instance as a simple structure/UDT
 
:+1:
 
with the first fields being the vtable pointers
(usually only one, unless you're implementing multiple interfaces)
 
oh you wanna something interesting, Wayne? Have you looked at decimal data type lately?
 
5:18 PM
like in 1999 or something :)
 
LOL. There are 4 different documentations about it and nobody agree on what it is.
Depending where you look, it is claimed to be 2 bytes big, or 12 bytes, 16, 17 bytes.
 
it's 16 bytes IIRC
 
To clarify - the 2 and 17 comes from Jet, IIRC.
 
actually that has to be wrong. it has to fit inside a variant in 32-bit land, which is 16 bytes in total
 
Yeah, that's what I would expect looking at the DECIMAL structure though funnily enough it says it's only 12-bytes big which is sorta true when talking about integer portions. but yeah, nobody agree on what it is.
 
5:20 PM
but 2 bytes for the variant header
 
so it's LOB?
 
yeah it will be 12 bytes. 2 bytes variant header, 2 bytes are reserved, leaving 12 bytes max
I'll find the definition, give me a minute
 
@WaynePhillipsEA What's the difference in member access vs content being read?
 
member access would be e.g. reading/writing to Variable.Field or Variable.Call(). But even just reading the object pointer value (e.g. with ObjPtr) would cause the object to be instantiated, not just member accesses
 
:+1: TYVM
 
5:25 PM
This is the definitive doc for decimal: msdn.microsoft.com/en-us/library/windows/desktop/…
It's 12 bytes
 
I am not a c++ expert but I count 16 bytes.
first is a union of 4 bytes, then another 4 bytes (HiLong) and then an union of 8 bytes
only 12 bytes are the "integer" portion.
the remarks in the header is a bit misleading.
 
no... it's USHORT + USHORT + ULONG + ULONGLONG
 
no
USHORT + USHORT + ULONG + ULONGLONG
 
sorry kid knocked me
 
no problem - so thatn's 16 bytes, no?
2 + 2 + 4 + 8
 
5:30 PM
hmm it is, and even the compiler confirms it. sizeof(tagDEC) == 16
So to fit in a variant, they are basically overlapping wReserved with the tagVARIANT vt (type)
 
so the vt doesn't point to a separate 16-byte structure?
interesting.
 
decVal is a union with the overall variant structure
Given that 2 bytes are unused (but reserved), I would say 14 bytes, but padded to 16
 
hmm. so that explains the "14 bytes".
From VBA side:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms221061(v=vs.85).aspx => 12 bytes.
https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/data-type-summary => 14 bytes

From Jet side:
https://msdn.microsoft.com/en-us/vba/access-vba/articles/fieldsize-property => 2 bytes
https://msdn.microsoft.com/en-us/library/bb208866(v=office.12).aspx => 17 bytes
sad, eh? 4 different documentation and nobody can agree. :p
 
and that 2 bytes? it made me wonder for long time if it's being treated as a LOB.
 
5:36 PM
Jet must be using some quantum compression algorithm to store 28 digit precision within 2 bytes of data
2
 
IKR!
 
You know what that 17 bytes rings a bell somewhere. I bet it's in the Access storage format
 
@IvenBach you've gone from "duh checks" to "duck checks" to "deck checks"? ;)
 
yeah TBH, those drive me crazy mainly cos they aren't powers of 2
it doesn't really make much sense to create data structure that aren't powers of 2. For database storage format, it might be OK since we wanna to pack every bytes but... it's still weird.
 
@FreeMan Your will awore of me bitter when #Words...
 
5:53 PM
aha... I've got your 2 bytes
In Access/Jet the field length for decimal is variable, dependent on the Precision that you specify in the table definition
If you specify a precision of 1, you get a 2 byte 'decimal' storage field
The maxiumum field size for the Decimal type in the Access/Jet storage format appears to be 13 though
 
clarify - each record has precision stored in the 1 extra byte?
 
no, the precision is stored at the table level
 
so it's actually 1 byte + 1*n byte, n being # of records?
(assuming precision = 1)
 
the sign will be stored in that additional byte for the 1 precision
28 precision == 13 bytes of storage
 
I see. That kind makes more sense - but from the documentation aboveyou'd never see that it's variable-sized field
 
5:58 PM
so the precision and scale are stored at the table definition level
Not sure on that 17 though
 
they must have been smoking something when writing that one.
 
the default precision of 18, yields a field size of 9
tell me about it
 
ok. very good to know. This makes much more sense that it'd be variable-sized field. Would be wasteful to pad 16 bytes everywhere if you only have a small number with small precision.
 
it has been a long time since I looked at decimal. thanks for the reminder. now lets put it back in the box for another 20 years.
 
Doesn't explain why it's so dang slow, tho.
LOL. Sorry!
Personally I never use decimal. Too problematic. I make do with Currency. Rare that we need more than 4 digits to the right anyway.
 
6:04 PM
well I guess it's probably slow due to the fact it needs to be parsed/extracted into a more consumable number format
 
Hmm. Yeah. That's the bad thing about the variable sized field.
 
if I needed big numbers (bigger than currency), I'd probably reach for a big number library rather than reach out into the unknown with the flaky support of decimal.
it always felt like it was unfinished. probably because it was.
 
and there's the Binary
that way you get a fixed size field and you can parse it whatever you like.
but the bad is that if you do that, you'll be using VBA to do that. Mucho slow than letting the C++ Jet do the parsing.
 
Oh yeah, wasn't that the one that used to be rendered in Unicode in earlier versions of Access? So you'd see chinese/japanese characters in the UI.
 
yeah by default, it'll be rendered as if it was a string.
 
6:12 PM
g2g thanks for the walk down memory lane :)
 
later
 
@this I don't know how you don't get bogged down in the minute details of stuff.
 
I live for this kind of stuff.
 
I just wish I could understand it.
 
it's a hockey stick.
 
6:26 PM
I keep trying but my progress is slow.
 
For a while it'll feel all confused and jumble-mumble but eventually when you have enough "background", everything will click
I promise!
I've been there where I only had lot of fuzzy notions and idea and "sort-of-understand-but-not-grok" for a long time.
 
I'm trying to get through bytecomb.com/vba-internals-getting-pointers and bytecomb.com/vba-internals-whats-in-a-variable. This is the best shot I've ever had at understanding the info.
Many times I feel like "Another Iven question..." and I'm the author of the questions.
At least my questions are showing improvement.
 
My Make Fields Readonly refactoring went out in VS 15.7 preview 4! It's even mentioned in the release notes!
9
 
@Hosch250 publicExposure++
 
6:37 PM
@this :click: Just understood IUnknown interface's methods AddRef, Release, and QueryInterface.
 
@MathieuGuindon So true.
 
@Hosch250 Very nice!!!
 
6:53 PM
@Hosch250 is making vanilla VS steal R# features, one at a time.
That wasn't an answer, that was a comment explaining why I'm voting to close this unanswerable question... — Mathieu Guindon 8 secs ago
#damn
 
@MathieuGuindon Small unrelated aside: In this post, I don't think this statement is strictly true:
> 'we need ScreenUpdating toggled on to do this:
If Not isUpdating Then Application.ScreenUpdating = True
I always turn off ScreenUpdating and don't turn it back on mid-macro, but using the StatusBar still works.
Maybe I'm missing some mechanic that allows me to do that.
 
until it doesn't, and when that happens, look at Application.ScreenUpdating
 
Anyway, very minor point, just letting you know.
Ah, okay. For me when it doesn't update then I need DoEvents, but I'll certainly keep what you said in mind.
 
DoEvents is likely overkill there
 
And obviously you mentioned DoEvents in the same code block.
 
6:57 PM
I ...
 
Most of the time when I use StatusBar it's because I'm in a tight loop.
> 'make sure the update gets displayed (we might be in a tight loop)
DoEvents
 
Cool, thanks for letting me know to be on the lookout, I will keep that in mind.
 
@MathieuGuindon Next up: Initialize From Ctor.
 
@Hosch250 YES!!!
that's gotta be the single R# feature I use the most without even realizing it
 
6:59 PM
Me too.
 
until I miss it in VS2015 at work
 
The only one that I miss.
 
@MathieuGuindon @SimonForsberg > If it's not a common error, then why would the question have 86 upvotes on Stack Overflow?
 
@IvenBach you just spawned a mod!
hi @SimonForsberg!
 
I'm in for it now.
 
7:01 PM
@IvenBach That's the joke?
 
@MathieuGuindon @IvenBach Quack!
 
Its Simon's comment. I happened to notice it.
 
ah, missed it lol
 
@IvenBach The guy had no idea what to do. Everything he said before looking it up on SO was him bsing. He had no idea how common it was.
 
@puzzlepiece87 I don't think so, it seems like Mr. Sysadmin don't know the issue at all, so I don't think he knows how common the issue is until he finds it at SO.
 
7:03 PM
@SimonForsberg Exactly.
 
@puzzlepiece87 But then why say "That's not a common error"?
 
@SimonForsberg To delay and give himself time to look up the answer on SO.
 
@puzzlepiece87 Why not just say "Oh yeah, that error" ?
 
@SimonForsberg A developer-god (the reputation he's garnering) would need to know the solution to common errors on the spot. He knows the rookie developer doesn't know enough to contradict his "not a common error" statement.
 
@puzzlepiece87 But one day the rookie dev will find that question on SO himself.
 
7:05 PM
@SimonForsberg He could say that too but that wouldn't be as funny.
 
Are over-analysing this?
 
@SimonForsberg Yes but that's after the reputation has already been cemented :D
 
Ah, I'm glad I'm not the only one sometimes pressing enter when typing '
 
@SimonForsberg No, y'all aren't analyzing it enough.
Need a thesis, please.
 
@SimonForsberg The answer to that question with regards to humor is almost always the same :D
 
7:07 PM
@this Then please help us analyze it.
 
@SimonForsberg Definitely not, I'm fat fingers for life.
@this I'll get started, how many pages do you need for my defense? :D
 
@puzzlepiece87 letter or legal?
 
The Humor of CommitStrip "That's Our Job" and Faking It in the Workplace - a thesis defense by puzzlepiece87
@MathieuGuindon Whichever fits more words :P
 
does any academic setting take legal papers?
think not. It's been letter AFAIK.
 
why can't I just ♪ let it go ♪
Again, VB's Open statement does not involve Notepad in any way. You seem to misunderstand how text files work. Notepad has a "word wrap" option that you likely have ticked; tick it off. If the problem is that a single Line Input statement brings the whole entire file into that variable, then open up your file in Notepad++ (then ditch both Notepad and Wordpad) and identify whether the line breaks are CR+LF or just LF (or just CR?). In either case, you'll need to clarify whether Texto_vetor_1(1) contains the whole file, keeping in mind that Notepad/Wordpad have nothing to do with this. — Mathieu Guindon 1 min ago
 
7:14 PM
@MathieuGuindon because, duty calls:
 
yes, exactly, duty calls ...as in dayjob duty :)
 
@this Arguing on the interwebs is like masturbating with sandpaper. Just don't do it.
 
yikes
that would probably make a good tweet :)
 
Disagreement is fine. Seeking to convince, not so much.
There's a reason I'm not on social media.
 
that user doesn't understand the difference between file and data ...
or more correctly: the difference betweeen opening an unformatted textfile with a rich-text editor and opening it with a text-editor...
 
7:22 PM
and the "word wrap" functionality of Notepad
I suddenly miss the good old "lacks minimal understanding..." close reason
 
^ Glad I came after that
 
811
Q: Can we please have the "Lacks Minimal Understanding" close reason back?

Benjamin GruenbaumThat close reason Yes, I believe it was condescending and somewhat rude. However there is a mass of questions that fall under a crystal clear criteria: They're poorly written. They have formatting issues. They don't show any research attempts. They don't show any attempt at solving the problem...

ah, this one:
31
Q: What do I do when it's clear OP cannot understand the answer?

Jared SmithIf this is a duplicate point me in the right direction, and I'll delete it, but all I found was this, the question it's a dupe of, and this one. Those seem related to the 'show me teh codez' questions. This question is about questions where the OP just doesn't have sufficient understanding to com...

You're not going to change this question once I answer it, are you? — tvanfosson Mar 22 '10 at 15:23
 
Those would be a bit off putting to newcomers.
 
7:41 PM
@IvenBach newcomers that don't understand that SO isn't your own personal debugging service / mentor
 
A "We're willing to help" faq/section would be good. Having it include "General expectations on your side" or better worded version to make sure they know what's expected.
I miss the bar on that often enough.
 
except people don't read
they come to SO, describe what they're trying to do to the best of their abilities, and when that's not good enough to make a question that makes any kind of sense, SO is suddenly the most evil place on Earth, full of power-hungry would-be-mods that take pride in policing the site and shutting down questions for no reason.
 
Except they're not.
Well some might be, on occasion. But we all have bad days.
 
oblig:
 
Can't teach those that aren't able to understand what you're presenting to them.
 
7:59 PM
@this do you have a moment?
 

« first day (1418 days earlier)      last day (1762 days later) »