« first day (1497 days earlier)      last day (1683 days later) » 
00:00 - 20:0020:00 - 00:00

8:02 PM
> I have symptoms of selective lysdexia and often type `VyBal` instead of `ByVal`...

I believe that there are discussions of code snippets/short-cuts that could be repurposed for this if one were allowed to define ones own snippets.
 
@Duga I don't see how there can be an end to this
FWIW when I'm done with AC you'll have to want to make a typo to mistype ByVal
 
need to consider the existing code, though.
I'm finding AC get in the way sometimes when editing some existing code.
 
hopefully once it's made parser-based rather than regex-based, it'll be easier to handle, maybe?
 
definitely
DAMMIT
3 hours wasted on a stupid infinite loop caused by a missing fetch next from c into @sql; statement
I hate cursors
 
8:14 PM
Thankfully, there's no situation that absolutely requires use of a cursor.
 
when you need to update a table on a MySQL linked server and update openquery ... from... join refuses to work and exec(@sql) at [MYSQL] works perfectly fine and you've wasted enough time on this already, yeah
 
still doesn't need a cursor for that.
 
no, need to waste more time
 
(I do hear you on the wasted time, though)
 
Hello Pond
 
8:26 PM
hola
 
hola
 
Am I getting a false positive inspection? I've got this:
Public Sub Foo
  Set notifier = New UserNotifier
  notifier.formField = Form_GenQuarterlyRpt.ProcessStatus
End Sub

'UserNotifier:
Public Property Get formField() As TextBox
  Set formField = this.formField
End Property
Public Property Let formField(ByVal Value As TextBox)
  Set this.formField = Value
End Property
and I'm getting Object variable 'formField' is assigned without the 'Set' keyword inspection
 
@MathieuGuindon What does member names mean please? Like .Value , .Count ?
 
also, when I apply the quick fix, I get this:
  notifier.Set formField = Form_GenQuarterlyRpt.ProcessStatus
which is definitely broken...
 
8:28 PM
@QHarr yeah
@FreeMan there are at least 5 open issues about that inspection
 
There were about to be at least 6... :)
 
@FreeMan not related but beware of using forms in that way.
 
both parts of the issue?
 
@MathieuGuindon Thanks.
 
if you want to reference a specific form, it's better to do something like Dim f As Form_MyForm : Set f = Forms("MyForm") and then subsequently refer to the f in your code. (there's an issue with the global instance but that is better than the syntax you are using ATM)
 
8:31 PM
@this I'm sure there...
I may not be using it the way you think I am...
 
notifier.formField = Form_GenQuarterlyRpt.ProcessStatus
 
'@Folder("Utilities.Tools")
Option Compare Database
Option Explicit

Private Type TInfo
  formField As TextBox
End Type

Private this As TInfo

Public Property Get formField() As TextBox
  Set formField = this.formField
End Property
Public Property Let formField(ByVal Value As TextBox)
  Set this.formField = Value
End Property

Public Sub NotifyTee(ByVal logLevel As logLevel, ByVal messageText As String)
  UpdateScreen messageText
  UpdateLog logLevel, messageText
End Sub

Private Sub UpdateScreen(ByVal messageText As String)
 
I'm not talking about the tee/notifier. I'm referring to the usage of the default instance (e.g. directly referencing the Form_GenQuarterlyRpt default instance)
 
ah, gotcha!
 
the advice provided in UserForm1.Show applies to Access forms/reports, too.
(the syntax may be slightly different but it still largely hold)
 
8:41 PM
thanks, @this. Brain is turning to mush at the moment, so I'll digest in the morning. Have to go pick up my new HD & start testing it before installing in the file server to replace a dying one...
the RD page is opened & ready to read in the AM.
TTFN
 
@this it's officially the most popular article on the blog now :)
 
@MathieuGuindon need to tell Google that then.
had to fight with it a bit to get the link....
 
hmm, it's still on the home page's side bar
 
groan should have thought of that.
 
Hm, isn't TextBox actually an object type?
 
8:45 PM
well, tbh, my default MO is to search
 
also, 2018 officially wipes out 2017 already:
 
i'm not so much for browsing through a list.
@M.Doerner indeed but there is no language restriction against you from creating a Let on an object.
in fact some libraries (I'm looking at you, ADO) support this abuse.
 
Doesn't that cause all kinds of problems?
 
Nope.
it just hurts the readability.
but it's perfectly legal to go like cmd.ActiveConnection = con or Set cmd.ActiveConnection = con. Both works equally well.
 
What happens if you provide a rhs that is declared as a subtype?
 
8:50 PM
then it depends on the implementation. It may error or may not.
remember, VBA loves to do all those voodoo implicit conversions, so it will try to convert whatever. If it succeeds, then everything's fine (for some value of "fine"). If not, you get a weird error that makes no sense.
 
9:11 PM
I just looked ist up: the spec says that you cannot assign an object via a Let statement.
What your ADO example does is something else.
The ActiveConnection has a Property Let taking a String, which sets the active connection to a connection based on the connection string provided.
 
ADODB.Connection default member is its ConnectionString, so ADODB.Command.ActiveConnection is ... ^^^^^ that
 
OK, you beat me to the rest.
 
I suppose ADODB then uses the connection string to pull an active connection from the connection pool... which might have interesting consequences given multiple open connections using the same connection string, where only one has an active transaction that you mean to use for the command
TL;DR: be explicit
 
The evaluation rule for Let statements is that the rhs is always first evaluated as a simple data value.
 
hmm.
 
9:15 PM
AFAIR, it will just create a new connection, but I might be wrong.
 
Private col As VBA.Collection

Public Property Let Example(RHS As VBA.Collection)
    Set col = RHS
End Property

Public Property Set Example(RHS As VBA.Collection)
    Set col = RHS
End Property

Public Property Get Example() As VBA.Collection
    Set Example = col
End Property
assume the above is named Class1
 
that compiles?
and runs?
 
Public Sub Test()
    Dim x As Class1
    Dim c As VBA.Collection

    Set x = New Class1
    Set c = New VBA.Collection

    x.Example = c

    Debug.Print x.Example Is c

    Set x.Example = c

    Debug.Print x.Example Is c

End Sub
 
expecting "invalid use of property"
 
Yes. Copy'n'paste, and see for yourself.
nope.
 
9:16 PM
Does that work at runtime?
 
that's bloody evil
 
totally legal to have all 3 property types.
and there's no default member involved here.
 
so we need an inspection for this
might be hard to implement though
 
that's why I think ADODB abused this, in spite of the Connection having a default member.
 
The spec only says that it does not work when actually using a Let statement at runtime.
 
9:17 PM
How so? Just check if it's an Object and verify that there's a Set, then yell.
@M.Doerner seems that it's ignored.
 
you could be passing an object only to let-assign a value backing field. violates principle of least knowledge, but still legit
 
Public Sub Test()
    Dim x As Class1
    Dim c As VBA.Collection

    Set x = New Class1
    Set c = New VBA.Collection

    x.Example = c

    Debug.Print x.Example Is c

    Set x.Example = c

    Debug.Print x.Example Is c

    Let x.Example = c

    Debug.Print x.Example Is c

End Sub
the Let still works.
 
The ADODB.Command is able to take a String. Since there is no function overloading, I do not think that it can take the connection directly via the let.
 
@M.Doerner ActiveConnection is a String?
 
Per documentation, the Get is a Connection object.
 
9:20 PM
so to compile every accessor/mutator must have the same type
so Set must be a Connection, and Let too
 
The Set takes a Connection object and the Let takes a String.
 
@MathieuGuindon I could have sworn there was an open issue for this.
 
Really, ADO is probably written in C++. So, there is no need to comply to VBA rules.
 
this explains that
definitely confusing
..and kinda simulates overloading
 
9:23 PM
[id(0x00000001), propget, helpcontext(0x0012c90b)]
HRESULT ActiveConnection([out, retval] _Connection** ppvObject);
[id(0x00000001), propputref, helpcontext(0x0012c90b)]
HRESULT ActiveConnection([in] _Connection* ppvObject);
[id(0x00000001), propput, helpcontext(0x0012c90b)]
HRESULT ActiveConnection([in] VARIANT ppvObject);
but thinking about it... I'm not so sure.
yes you can assign a string.
but consider that the connection string changes when you open the connection
and if you've set Persist Security Info = false;
the connection string is now incomplete.
so therefore, if you had a connection string that had a user/password included, that would not work, right?
 
ugh. haven't used not-SSPI integrated security in VBA code in years
db passwords in VBA code is dumb IMO. unless you're not on a domain.
 
we do password-based login a lot
in those projects the rule is to throw it away once we open.
 
the [very junior] DBA in me says "just no"
 
@Comintern yeah, I'm almost certain we've made this discovery before. ActiveCommand being the example last time too.
 
@this if you prompt the user for it, then fine.
 
9:31 PM
@MathieuGuindon Of course. How else we will throw it away?
we never store password. Period.
 
but then, if you're on a domain, prompting the user for a password is... annoying, no?
 
Yes in those projects they aren't. so.
 
so we agree then :)
 
What I'm trying to remember is if you can bypass the VBA restriction by memory hacking the vtable.
 
so many VBA projects hard-code creds in connection strings though
 
9:33 PM
@MathieuGuindon wrong, wrong, wrong
Confirmed.... with a password-login, Let cmd.ActiveConnection = con has to be using the object, not the default member
because if I take the value of the con.ConnectionString and apply to the cmd.ActiveConnection, it errors saying that the user is not authenticated (no password)
but applying the open con to the cmd.ActiveConnection (whether without any explicit keyword, with Set, or Let) all succeed.
I think it's reasonable to assert that the default member is not involved here.
@Comintern restriction of what?
 
@this Types matching on the Get Set and Let.
 
@this that alone warrants a library-specific inspection
 
I'd imagine that you'd want them to be the same size to avoid access violations, but it might work.
 
hmm.
from what I see, VBA doesn't have that restriction, exactly.
Public Property Let Example(RHS As Variant)
    Set col = RHS
End Property

Public Property Set Example(RHS As VBA.Collection)
    Set col = RHS
End Property

Public Property Get Example() As Variant
    Set Example = col
End Property
so is this:
Public Property Let Example(RHS As VBA.Collection)
    Set col = RHS
End Property

Public Property Set Example(RHS As Variant)
    Set col = RHS
End Property

Public Property Get Example() As VBA.Collection
    Set Example = col
End Property
but not all permutations are legal, though.
this gives a compile error:
Public Property Let Example(RHS As VBA.Collection)
    Set col = RHS
End Property

Public Property Set Example(RHS As Variant)
    Set col = RHS
End Property

Public Property Get Example() As Variant
    Set Example = col
End Property
 
@this Huh. I must have been hitting all of them.
 
9:42 PM
it almost looks to me that Let and Get must be in the lockstep
But Set.... it's its own thing.
Hmm. In the ActiveCommand example, though it's the Let that don't match.
 
Public Property Let Example(RHS As Object)
End Property

Public Property Get Example() As IDispatch
End Property
 
the Get (propget) and Set (propputref) takes a _Connection while the Let (propput) takes a VARIANT
 
Wonder if it checks for the restricted interface before or after the other check...
@this That actually makes some sense. The interface isn't making assumptions about the strength of the typing in the calling code. Isn't everything VARIANT in VBScript?
 
@this I presume this stops working if you change variant for string
 
@MathieuGuindon ha, I just tested that.
but not when you use a different unrelated object (e.g. VBA.Collection and DAO.Recordset
 
9:50 PM
Gosh VBA is so borked
 
so yeah, you really can't mix primitives in the property procedures. But you could mix object types because again, VBA has no idea about the object hierarchy.
it won't guarantee that VBA.Collection is castable to DAO.Recordset. that'll have to wait until runtime.
but yes it's borked.
probably because Microsoft had some PHP kids working on it, who knows.
 
@this no idea of type safety
 
Yeah -- Recall there's an open issue for case where the Nothing is dispatched through different types with no runtime errors whatsoever. But pass not-Nothing => RTE13.
 
Unrelated,...I like when I write a tweet and it just so happens to be exactly 280 characters
 
Need a word for that.
Tweet-ku?
 
9:59 PM
lol
 
@Malachi need to watch that entire video. First couple mins with ‘baby mode’ made me smile.
 
saw. didn't like it. They should be asking for some stacktrace API instead.
 
@ITImpactInc I'm all for improving the VBE, but this is an objectively very terrible and backwards idea with horrendous implications. Please don't do this.
@this amended my comment =)
TTGH
 
10:15 PM
@MathieuGuindon :+1: Yes, they should be buying watchdog and making it built-in.
 
@MathieuGuindon pretty sure that "ITImpactInc does not understand how wrong that proposal is
 
Say wut? Going back to line numbers?
Isn't that like saying "I want to go back to using corn cobs. None of this toilet paper for me."?
 
Keep in mind that when it's all you know, it's easy to think that it's an improvement.
 
Grrrrr.... Why can't I run unit tests?
[7/12/2018 5:20:55 PM Informational] NUnit Adapter 3.10.0.21: Test execution started
[7/12/2018 5:20:55 PM Warning] Exception System.IO.FileNotFoundException, Exception thrown executing tests
[7/12/2018 5:20:55 PM Warning] Could not load file or assembly 'System.Xml.XPath.XmlDocument, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
[7/12/2018 5:20:55 PM Warning] at NUnit.VisualStudio.TestAdapter.NUnit3TestExecutor.RunAssembly(String assemblyPath, TestFilter filter)
 
10:45 PM
PSA: Don't work off ActiveSheet. ActiveSheet is Object, which means every member call is a late-bound IDispatch query on the object's vtable, i.e. recipe for error 438. Declare/use an actual Worksheet object instead, and enjoy IntelliSense and compile-time validation. #VBA #Excel
 
Finished that excel video and quite a bit came off as elitest... #Irony
 
> If I'd asked them what they wanted, they'd have said "faster horses"
 
11:04 PM
> @daFreeMan Agreed. I've been using MZ Tools Code Library with expansion shortcut it works well - when I remember to use it. Was also trying to learn C# so played in VS for a while and thought I'd gone bat s..t crazy when I returned to VBA to discover auto-correct... Hopefully RD could bring something similar but without having to press the expansion shortcut... (just pressing SPACE &/or ENTER would be awesome).
 
visual studio
:smack: :smack: :smack:
 
00:00 - 20:0020:00 - 00:00

« first day (1497 days earlier)      last day (1683 days later) »