« first day (152 days earlier)      last day (3028 days later) » 

00:00
plus EF and List<MyTable> bla bla ...
alright im probably being annoying so im gonna gtfo :P
but the idea is that something that used to take me an hour of coding ( not HARD just typing ) takes me 3 minutes to achieve using C#
I'm in deep. I'm trying to translate this to c#, but having trouble with translating the events.
is that in relation to your last post on SO?
LOL. Yes.
I decided it was best to just build the COM Add-in, but I'm still learning C#.
I could do it in VB.Net, but I need to catch up to the times.
you will always be learning C#
2
;>
Hey Mug
00:04
yo bro
someone at the office asked me earlier today
"HOW MANY VARIABLES CAN YOU MAKE IN EXCEL VISUAL BASIC"....
Oh no.......
Did you teach that person how to loop?
I smell a need for looping.
@vba4all did you answer with the actual limitation?
@Mat'sMug There is one??
Okay....... that is seriously way too much work to wire up an event. I'm going to have to post this to CR when I'm done.
00:13
naugh... i pretty much said : " OH SORRY I HAVENT DONE ANY VBA IN AGES... IM NOT SURE ABOUT VBA'S LIMITATIONS"
00:38
Assuming they're the same as VB6, yes there are!
in The 2nd Monitor, 1 min ago, by rolfl
@Mat'sMug - your help, please ;-)
01:22
I think I've got it. Just need to wire it up to a command button to show it.... and then the real fun starts......
It's actually a nice exercise to translate code from a language you're kind of familiar with to one you're not.
01:41
@RubberDuck I usually register events, like, button1.Click += [tab][tab] done.
I'm pretty confident that I did it the hard way @Mat'sMug. Lol. It's real ugly right now. I'm going to have to clean it up a good bit.
11
A: What is the return type for an Event in .NET?

retailcoderIt depends on the type of the delegate you declare the event with. "Typical" events are declared with a delegate of type EventHandler or EventHandler<TEventArgs> which returns void, but nothing forbids declaring an event with a different type of delegate... if not the Principle Of Least Surprise ...

ugh. I meant this one:
6
A: Understanding events and event handlers in C#

retailcoderJust to add to the existing great answers here - building on the code in the accepted one, which uses a delegate void MyEventHandler(string foo)... Because the compiler knows the delegate type of the SomethingHappened event, this: myObj.SomethingHappened += HandleSomethingHappened; Is totally...

01:58
Dude... That is so far off from the MSDN tutorials it's ridiculous....
I'll take that as a "well that's much simpler, thanks Mug!" ;p
02:17
one down:
            var hasOptionExplicit = false;
            if (module.CodeModule.CountOfLines > 0 && module.CodeModule.CountOfDeclarationLines > 0)
            {
                hasOptionExplicit = module.CodeModule.Lines[1, module.CodeModule.CountOfDeclarationLines].Contains("Option Explicit");
            }
            module.CodeModule.AddFromString((hasOptionExplicit ? string.Empty : "Option Explicit\n") + TestModuleEmptyTemplate);
            module.Activate();
not the prettiest fix though
wow GitHub is smart!
> retailcoder referenced this issue from a commit 27 seconds ago
02:56
Lol. Yes. Much simpler @Mat'sMug and github is wicked smart.
Lol. Yes. Much simpler @Mat'sMug and github is wicked smart.
03:09
@RubberDuck the other issue is about to spawn a SO question
it's not because you're calling a function, it's because 2 all by itself is an Integer (which .net correctly receives as a short), and comparing it to a Long value of 2 (which .net correctly receives as an int) results in an inequality.
03:26
Right. I thought that's what was happening.
@ticker whenever you're ready ;)
0
Q: What if I don't want type safety?

retailcoderI'm writing a little VBA IDE add-in, and there's a COM-visible C# class called AssertClass, with an AreEqual method that goes like this: public void AreEqual(object value1, object value2, string message = null) { if (value1.Equals(value2)) { AssertHandler.OnAssertSucceeded(); ...

@ticker 3 minutes.. you beat @CaptainObvious by like 10 minutes!
03:57
@RubberDuck the actual code I've used:
        public void AreEqual(object value1, object value2, string message = null)
        {
            object convertedValue2 = null;
            if (value1.GetType() != value2.GetType())
            {
                try
                {
                    convertedValue2 = Convert.ChangeType(value2, value1.GetType());

                }
                catch (Exception exception)
                {
                    AssertHandler.OnAssertInconclusive(exception.Message);
                }
            }
Lol. Yeah @Mat'sMug. Posted a comment within seconds.
Pssst. You're catching exception.
This is a CR chat after all. =)
argh
lol
tltstdtts
too lazy to switch to desktop to star
04:36
@RubberDuck got one for you
'@TestMethod
Public Sub CompareBoolean()
    Assert.AreNotEqual CBool(1), 2
End Sub
vs
'@TestMethod
Public Sub CompareBoolean()
    Assert.AreNotEqual 2, CBool(1)
End Sub
one passes, the other fails.
....
thoughts?
05:19
not sure I like the fix
it gives value1 a different meaning than value2, and makes the order matter. Assert.AreEqual 300, CByte(30) and Assert.AreEqual CByte(30), 300 will produce very different results...
 
5 hours later…
10:38
My opinion @Mat'sMug: Document that AreEqual will fail if not the same type and move on. It's not that inconvenient to write Assert.IsTrue( CByte(30) = 300)
My opinion @Mat'sMug: Document that AreEqual will fail if not the same type and move on. It's not that inconvenient to write Assert.IsTrue( CByte(30) = 300)
OR change the parameter names somehow to make it clear that the order matters. (And document the shit out of that too...)
10:58
/// <summary>
/// Asserts that two objects are equal.
/// </summary>
/// <remarks>
/// This method will attempt to cast `actual` to `expected`'s type, but not expected to actual. [insert example here]...
/// </remarks>
public bool AreEqual(object expected, object actual)
11:12
Then the client code looks kind of like

Const expected As Long = 2
Assert.AreEqual expected, 2
Which is nice, because now you're explicitly saying "I expect this foo to be a bar when I get it back"
11:28
Yeah. I'll just document the type-safe nature of the AssertClass, and move on. I don't want all these side-effects and edge cases.
 
2 hours later…
13:37
If I do a massive "Find/replace" on "As Integer" and replace it with "As Long" - does this have any potential to cause problems?
Ughh...... Not sure I would replace all.
I know I couldn't, because I've written too damn much meta code....
Do you make any API calls?
oh shit
yeah
Glad I asked first. bwahaha
Yeah. I would make sure to test changes to the Win API. They might need integers still.
Let me know though... I should probably update my SO answer if so.
14:05
I was thinking about this though, if VBA automatically converts behind the scenes Integer to Long - does it do this on declaration? or instantiate?
It's all about how it gets stored @enderland. It happens very close to the metal.
3
A: Integer Vs Long Confusion

RubberDuckAn integer declared as an Integer is still type checked as an Integer. The msdn documentation is referencing how the variable is stored internally. On a 32 bit system, an Integer will be stored in 32 bytes, while on a 16 bit system, it would have been stored in 16. Hence the maximum size. There...

Hmmm. So if an API call expects a 16bit integer, how does that actually work I wonder
14:35
@RubberDuck oh funny, I just realized that question was from yesterday
I'm pretty sure it's not even talking about in memory
I think it's just referring to the fact that registers are 32 bits
I use CopyMem for a bunch of things and I've never run into a case where I needed to treat an Integer as 4 bytes
14:50
Is there a way to check how much memory space it actually takes up @Blackhawk?
0
A: Integer Vs Long Confusion

enderlandI don't believe that documentation. Consider the following simple example: Sub checkIntegerVsLong() 'Check the total memory allocation for an array Dim bits As Integer 'or long? :) Dim arrInteger() As Integer ReDim arrInteger(1 To 5) arrInteger(1) = 12 arrInteger(2) = 45...

yes :P
I literally just posted an answer doing so
I would be very curious what that returns on different versions of Office
Well, you can check the Lenb()
Or you could create a Type
Public Type Test
a As Integer
b As Integer
End Type
and just check the VarPtr()s
c As Integer
@Blackhawk won't that check the string length? not the variable length?
Create some local variables in a function and use the VarPtr to read the memory "around" an integer to see if the other integers are right up next to it
Len = String length
LenB = byte length
you can use LenB on any variable type
including Types
Like this?
Private Sub test()
    Dim i As Integer: i = 10
    Dim l As Long: l = 10

    Debug.Print "i : " & LenB(i)
    Debug.Print "l : " & LenB(l)

End Sub
15:01
Should work
> i : 2
l : 4
2 bytes is 16 bits...
yes
So VBA still stores Integers as 16-bits (unlike modern sane languages :P)
My guess is that the article is referring to how, to get a 16-bit value into a 32-bit register, some masking has to be performed
Except they actually use the word "Type"
or some such
which is hugely misleading if that's the case
@RubberDuck hehe I just added something similar into my answer there
Pretty sure Integers are not auto converted..
15:04
Public Type Testing
a As Integer
b As Integer
End Type

Public Sub Test()
Dim atest As Testing
Debug.Print VarPtr(atest.b) - VarPtr(atest.a)
End Sub
displays 2
Where's Spolsky when you need him.....
@Blackhawk do you mind if I include this in my answer there?
@enderland Go for it!
Public Sub Test()
    Dim a As Integer
    Dim b As Integer
    Debug.Print VarPtr(b) - VarPtr(a)
End Sub
Here's a fun one
turns out, function local variables are stored in reverse order
(pushed onto the stack in reverse order?)
@Blackhawk Interesting nugget. =)
thanks @Blackhawk, all the examples are in the answer i have there stackoverflow.com/a/26760080/1048539
@Blackhawk how do you figure?
> Sub testIndividualValues()

Dim j As Long
Dim i As Integer

Debug.Print VarPtr(i)
Debug.Print VarPtr(j)


End Sub
> 3731246
3731248
that prints consecutive memory addresses:
15:13
Yes, it does, because you're printing them in reverse order
If VBA stored them in the same order as you declared them, j would have a smaller address than i
Oh wait... the stack grows downward
wait, I just realized I declared them backwards
enderland fails
It looks like: 1. The stack grows downward (successive things pushed on the stack get smaller memory addresses) 2. VBA pushes local variables onto the stack in the order you declare them 3. Therefore, the first local variable has the largest address and the last the smallest
2
Private Declare Sub CopyMemory Lib "Kernel32.dll" Alias "RtlMoveMemory" (ByVal Destination As Long, ByVal Source As Long, ByVal Length As Integer)

Public Sub Test()
    Dim a As Integer
    Dim b As Integer
    Dim c As Integer

    a = 1
    b = 2
    c = 3

    Dim arr(0 To 5) As Byte

    CopyMemory VarPtr(arr(0)), VarPtr(b) - 2, 6&
End Sub
There's the last one I can think of
loading b and the 2 bytes before and after it shows that the three Integers are right next to each other, two bytes each
(inspecting arr in the watch window)
15:53
What is this sorcery? ;) lol hi @Blackhawk!
16:04
:D hai!
16:16
@Mat'sMug there's always sorcery to be found when @Blackhawk's around.
Okay. Seriously....... what is that sorcery?
Someday I will learn all about that CopyMemory stuff.........
16:40
It's good stuff!
Is VarPtr a builtin to VBA? Also do I need to be familiar with the windows kernel to know how to make these alias?
VarPtr is built-in to VBA
You can look up the Win32 APIs on msdn and make the declarations from that
Here is the CopyMemory page on msdn. You can see that the actual dll entry point is called RtlMoveMemory, and if you scroll down to the bottom, you can see that the dll is Kernel32. The function returns void, so in VBA it's declared as a Sub. The arguments are both void pointers, so as long as you pass an address, it doesn't matter how you do it.
Private Declare Sub CopyMemory Lib "Kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Integer)
Defining it that way, VBA will pass the address of whatever variables you use for Source or Destination
That's effing magical.
2
With the exception that strings and arrays wouldn't be handled correctly
why?
are they not in neighboring memory like in C?
16:47
VarPtr(arr) wouldn't get you the address of an array
Arrays and Strings aren't actually stored directly in memory like most languages.
it gets you the address of the SAFEARRAY structure that describes the array
To get the actual address of the data in the array, you could do VarPtr(arr(0))
Variants complicate the issue even more, since they are a 16-byte data structure that describes what it contains
4
A: VBA check if array is one dimensional

BlackhawkIf you REALLY want to avoid using On Error, you can use knowledge of the SAFEARRAY and VARIANT structures used to store arrays under the covers to extract the dimension information from where it's actually stored in memory. Place the following in a module called mdlSAFEARRAY Private Declare Sub ...

VBA uses BSTR structures to store strings. Here is a better explanation of what that looks like in memory.
Okay..... this one has me stumped. It seems that the form error bubbles directly to the top, which in a way makes sense I guess. But does anyone know why?
@RubberDuck: Thank you for a reply, however, when I put a button onto the addClientForm and raise the error only in this button's _Click event, the behaviour is still the same - the error appears as unhandled. — Daniel Bencik 9 hours ago
17:04
@DanielBencik verify your options, in the [General] tab, in the [Error Handling] section - make sure "Break on Unhandled Errors" is checked. — retailcoder 13 secs ago
@Mat'sMug Not it. I checked mine.
Good thought though.
If you put error handling in the button (on the MainForm), that catches the error in AddClientForm.Initialize
It appears that .Show won't bubble up errors
or something...
I don't get it, but I think I have a workaround. Not one I like, but a workaround regardless.
 
2 hours later…
19:34
I noticed most of you work with databases for a living using tools like LINQ.
data data data
0
Q: VBA ClickBot featuring AJAX waiting and Element searching

ptwalesIf you work with a database that you only have access through a web interface, this one is for you. You probably don't have access to any programming languages other than VBA through MS Office, which I 95% guarantee you do have. Since we will be controlling an external instance of Internet Expl...

did I even mention I am super jealous?
Oh what @ptwales?
Direct access to database.
19:42
Oh! Yeah. It's nice to just pop open SSMS and write a query.
Hearing yall talk about writing some LINQ code to get data while I'm plowing through the HTML code finding the element I want to click.
But to be honest, I don't like SQL all that much. I really prefer to build programs.
Yeah. That's crap.
I could so do this man.
Who the hell is that.
I bet he is on here already or will be soon.
I don't know. Don't much care.
It's the idea of it. someday being able to work for myself and just myself.
$20 an hour for writing VBA
I wonder how much business (s)he gets.
19:48
Idk, but it's honestly an all right rate. Probably a side gig.
$20/hr for software dev consulting is pretty low if you know what you are doing
That's why I'm thinking it's a side gig.
Hmmmmmm I could do that.
I think I might be under contract preventing me from doing side jobs
or maybe that was Epic...
LOL. This person has lost their mind.
> Est. Budget: $7.00
link blocked...
20:02
That's okay, here's all you need to know.
> Looking for someone to help us with editing excel 2010 VBA macros. We’ve made some vba macros for daily inventory updates for our business. We need someone who is knowledgeable in excel vba macros and can help us make our codes better. Offering $7.00 for 2 hours session Similar task may be offered again if it works out well Depending on the situation, we may ask you to create a whole macro. More tasks may become available.
We may ask you to create a whole macro.
lol
For $3.50 an hour...........
Are they marketing to India?
Not even a Chinese citizen would take that.
And it's a whole macro. That means they want 300 lines of code......
bhabhabhbahbhahahahahhahaha
We should counter offer for $30/hour
HR people like it when you smack them in the face
I don't like HR people.
And it's contract. Are they out of their minds?
20:08
I think they're really aliens come to take over the world.
Problem with stuff like that is that you might get someone who does it from a low cost of labor country and it is basically free, or you might get someone completely clueless
"Seeking Programmers Fluent in SQL, C#, Ajax and ASP.NET"
@enderland then they get shit code.
BUT ITS CHEAP!!!!1
The ones that scare me are the "need help updating this access database I built 10 years ago".
I'm fairly sure that actual developers in India don't get paid $3.50 an hour.
20:11
Est. Less than 1 month, less than 10 hours a week.
"I Built"
oh dont even get me started on outsourcing dev work
It's like, sure. I'll do it, but you don't get to see the code until it's done and it's going to cost you 2 to 3x that price.
I'm currently trying to figure out how to get people with no idea about VBA/databases to support my current project
20:12
"Purchase a solution"
You mean you aren't the support @enderland?
I should make a list of phrases I have hear that I hate in the field.
@RubberDuck I'm seriously torn between thinking that it will actually be less overall work for me to just say "I will support any breakfixes" vs trying to get people without any idea of the process or technology up to speed on actually being able to support it without talking to me through the process
Top of the list is "See Below, Please advise". The only content in the latest email of a long email train.
"sure, my advice is you are an idiot" doesn't work huh
20:14
@ptwales I actually just scolded one of the managers (not mine) the other day about doing that.
> In the future, please provide me with this kind of information up front. Saying "see below" leaves me grasping at straws and inevitably makes me look like an idiot.
I would be scolding everyone if I did it. "see below" means you are too lazy to tell me what the problem is and "please advise" means you are too lazy or stupid what you are asking for.
2
So for the next 15 minutes I am transported back to elementary school for a game of Myst.
I loved hated that game.
Same. You needed to read the entire library to know how to do anything. I can respect liking that but reading a book on a 640x480 is a no go for 10 year old me.
did stars result in rep?
I don't remember having 1,596
If only stars resulted in rep. =)
just badges
20:48
I don't have 1,596. What is that number.
Is that my net rep?
Yeah. Net rep for all SE sites I think.
21:06
These new feed items are annoying but usefull.
If only there was an tag
just filter on that
Be liberal with upvotes and downvotes.
Reward those who want to understand and punish those who just want their work done.
4
Guys, it's up to you. I can shut the ticker off.
Or change the search.
For example, I've considered not allowing any items tagged ......
This is the search it uses right now.
http://stackoverflow.com/feeds/tag?tagnames=vba&sort=newest
not allowing macro is a good call.
or whatever the formatting for tags are.
[tag:macro]
Okay. Give me one minute. Should I add the lang specific tags too? We probably aren't seeing all the vba related questions.
Okay... one thing at a time I guess. I don't think I can do (vba or excel-vba) and NOT macros.........
21:28
RubberDuck has made a change to the feeds posted into this room
 
2 hours later…
23:32
@RubberDuck well, that ticker got me more SO rep in a week than in the past ...year.
23:52
Lol. Right?
@Mat'sMug if it seems like we're not seeing better questions or feels like we're missing stuff feel free to change it.
sure :)

« first day (152 days earlier)      last day (3028 days later) »