@IvenBach The situation is the same at my workplace. In addition to being used to it, it is valued that no interaction with the IT department is required.
Whenever I have spare time, which does not happen too often, I try to clean up a few things I work with myself.
I mean, I am not clear if ClassModuleDeclaration.References gets all the references contained in the class module or all the times the class module is referred to throughout the VBA project.
@theVBE-it'srightforme This should be close to what you are after (I think) var allReferences = _declarationFinderProvider.DeclarationFinder.Members(<ModuleDeclaration>).SelectMany(dec => dec.References);
It is just the standard "cannot load" error that they already recognize, just that the step of changing the option in Debugging - General doesnt fix it.
I guess I thought I would bring it up here and see if there was something else obvious I was missing first since that often seems to be the case.
@BZngr That gets the references out of each member in a given module?
@this Speaking of which, has anyone heard from comintern? It seems like close to a year since we last heard from him. Even James Bond's missions don't last that long!
Private Sub UserForm_MouseMove(ByVal X As Single, ByVal Y As Single)
If (X Mod Y = 0) Then
With TestUserform
.Height = 2 * Y
End With
TestUserform.ChangeFormControlFont(TestUserform)
End If
End Sub
Public Sub ChangeFormControlFont(ByRef frm As Object)
Dim cntrl As MSForms.Control
For Each cntrl In frm.Controls
cntrl.Font.Name = ""Anything But Calibri""
Next
End Sub";
I so enjoy the implicit black voodoo conversions. They make my life sooo easy!
Public Sub x()
Dim l As Variant
Dim r As Variant
l = 1
r = "1"
Debug.Print l, l = 1, l = "1"
Debug.Print r, r = 1, r = "1"
Debug.Print 1 = "1", l = r
End Sub
@IvenBach I both understand that their decision is permanent for the foreseeable future and also wouldn't be surprised if somewhere down the line they eventually abandon it because good golly what a poor decision.
It's far too easy to write sloppy code that does implicit conversions that you weren't expecting (or one that doesn't when you were expecting it, too).
@theVBE-it'srightforme Well, it's both. It specifies that, for example, the "Form1" component (the object and the code-behind) are a ComponentType.UserForm
I have a duck check as well: if I need the results of a function for use as a method parameter but I have no need for a callback delay, does it matter which of the two following options I do?
Interesting. I seem to be getting lot of inspections similar to this: Member 'xxx' has a 'VB_VarHelpID' attribute with value(s) '-1', but no corresponding annotation.
@theVBE-it'srightforme makes sense - some companies consider their code proprietary and don't want people posting it to GH, nor do they want to deal with the licensing issues of incorporating OSS code licenses into their paid applications.
@puzzlepiece87 we're all kinds of HIPPA here, but GH is available. Of course, I doubt that many here do anything more than "Joe in Accounting's VBA"...
Interesting. I seem to be getting lot of inspections similar to this: Member 'xxx' has a 'VB_VarHelpID' attribute with value(s) '-1', but no corresponding annotation.
Rename the UserForm1 to NaughtyBits. That may help dissuade them from showing it.
@theVBE-it'srightforme it's simply suggesting that I add the attribute annotation because it has a non-default attribute for help ID. But I'm seeing that flagged for all variables that has WithEvents, so it's kind of noisy.
I have a desire to have a dynamic collection where the key can be early bound.
Example: Controls(SourceForm.SomeControl.Name).Value instead of Controls("SomeControl").Value
With Access forms, any controls are added to the interface, so the dot access is possible and thus can be verified by the compiler. But I don't want it to be tied to only one form. #FML
@BZngr Considered that but 1) would have to be the LCD among implementations, 2) wouldn't early bind the different members that might exist on one implementation but not other. @mansellan is correct; I want the moon on a stick.
Design feedback question: if I'm processing an indeterminate number of files in parallel and am trying to make a progress bar more informative than like
0%.... 0%..... 0%..... 20% 47% 100%
Would you all do something like multiply the file count by 4 and implement quarter-file progress increases?
@HackSlash Sure, but I'm asking what you would recommend to keep your users happy if you start on many/all of the files at once... there's a delay, and then many/all finish at once.
(Trying to avoid a situation where progress is 0% for awhile, then suddenly 100%)
Oh! Well, I can tell you what Microsoft does: Lie. They do a time based count to 80% and then the rest is based on real information like the files completed.
But the thing is that if you aren't collecting them upfront, you don't have the max value.
and without max value, your progress bar might not make sense
I suppose you could add to the max value as you start a new file but that might look weird to people looking at the progress files ("hey why did it go from 50% to 37%?!?")
Except there needs to be a thread for that code calling ProcessSingleFile, it has a wait in it. The UI would kick off that thread and it would do a Parallel for each on all the files.
Got it! Thanks! I first started looking into asynchrony to relieve the UI thread, but it looks like that's not enough. What I'm taking away from what you're saying is that asynchrony is helpful but is not enough on its own to free up the UI thread. The asynchronous work needs to be assigned from a different thread altogether.
It's complicated and I'm no expert but I know that the UI thread only calls an action and returns. Or it reacts to stimulus by updating the UI. You never have a _Click event waiting for the click action to be done. If you want to disable the button then do so.
Public Sub Foo(Optional Bar As IBar = Nothing)
If Bar Is Nothing Then
Set Bar = New IBar
End If
'Do stuff
Bar.DoMore
'Do more stuff
Bar.DoThisToo
'Wrap up
End Sub
The alternative would be:
Public Sub Foo(Optional Bar As IBar = Nothing)
'Do stuff
If Not Bar Is Nothing Then
Bar.DoMore
End If
'Do more stuff
If Not Bar Is Nothing Then
Bar.DoThisToo
End If
'Wrap up
End Sub
In my opinion, which counts for nothing because I'm no expert, I think it's fine. If you're trying to make like, hyper clean code, then sure, but I think what you're doing quickly and neatly accomplishes your functional intention.
If do stuff, do more stuff, and wrap up really don't need bar, if I was trying to make hyper clean code, maybe I wouldn't even put them in the same method, but that obviously depends on context that you can see and I can't.
I understood previously that if Bar is not nothing, then you need them between, which I abbreviated as (your method), but it seems you are telling me you must execute methods that might be empty, which I don't understand but I accept.
I remember and still think you know about Excel because I conflate Excel and VBA
old habits etc
Anyways yeah they do. I would think it is less common to have that self-reference issue with them since examples usually use Me (not that they typically explain what Me is very well) and the lazy approach is to not qualify at all, but still.
Also I realize I'm a bit muddled. In both Access forms and Userform, you can do Form1.Whatever for either. The proposal is to change that into Me. This actually works even for the predeclared classes, too.
So it's not actually something to do with being a document.
It's all about using a class to reference to itself using its name instead of Me