« first day (1056 days earlier)      last day (2124 days later) » 
00:00 - 18:0018:00 - 00:00

6:00 PM
That's a cast
You're explicitly converting it from one type to another.
 
Ahh, that makes sense
I only knew casts from a tutorial like 1.2f
 
I didnt know you could cast using the prefix
 
From what little C# I know, any time a loss of data can occur an implicit cast cannot be performed.
You have to explicitly do the cast yourself with ( )
Take all my advice with some salt, I've been known to misunderstand things.
Lunch Time!
 
Np lol
 
6:06 PM
@BrandonBarney that's not a cast :)
it's a float literal
 
I have no clue what I am doing obviously then
 
@Mat'sMug Aren't all decimal number by default doubles?
 
a bit like 1.2# in VBA -> 1.2 is a Double literal
 
So literals basically are when we define the type alongside the value?
 
it's mostly useful when you want to be clear about what type is involved, and in VBA avoid implicit type conversions and possible stupid integer overflows
?TypeName(123)
  Integer
 
6:08 PM
@BrandonBarney Hmm, now I'm contemplating doing the same thing with e-mails. I'm hesitant to do that because I don't want things to break or to have the user get e-mail delivery failure notifications just because my e-mail address is unreachable (I'm no longer with the company).
I'm in a similar situation, my colleagues have very limited trouble-shooting ability.
 
You could have it send to a generic email that gets rerouted based upon your department.
See if you can get a 'department' email
In my case though, my boss has enough knowledge that he could go in and edit the macro if needed
 
If we can get even one more person on my team who programs, I will request that.
Doing it just for myself, when it's uncertain if I would be replaced with a programmer, would probably be viewed as overkill despite my very supportive working environment.
But great suggestion.
 
Yeah, you can always for now just messagebox your user and save a log file somewhere. I store the log file in the same location as the macro, but I have used the tmp environ as well. You can also always have a low-tech debug tab
Make it veryhidden to the user, and you can come in and unhide it to see the info
I think I know the answer, but can I skip disposing an object by overwriting it with a new object?
I am guessing that is a terrible idea, but I also hate the idea of having to declare and dispose a ton of pivotfields.
 
6:29 PM
@BrandonBarney I don't envy you at all for having to work with Pivottables via VBA, it is awful.
 
I absolutely hate it, but it is the only way to get the data I need lol. For the most part they behave just fine, but there's always that project I thought would be 'easy' and suddenly things dont work right.
I pretty much refuse to build them with VBA thoug
 
@BrandonBarney That's another idea I should have thought of, I already write a debug file for every program-performed query.
I will do that
 
Glad to help :)
 
@Mat'sMug, as I tend to do when I file things away as homework and come back to them with better understanding, I think I figured out why my drop table commands weren't working reliably to drop local temp table variables before.
I was using if object_id('tempdb..#temptable') is not null drop table #temptable;
Seems to say you can't do that: "The full name of a temporary table as stored in the sys.objects view in TempDB is made up of the table name specified in the CREATE TABLE statement and the system-generated numeric suffix."
I'm assuming from that statement that my drop commands weren't finding my local temp table variables because they lacked the system-generated numeric suffix
 
huh, why not just drop table #temptable;?
 
6:35 PM
I think I may have also lacked one or two of those and fixed it later not realizing what was going on.
I have like 9 temp tables in this compound query
So before I mistakenly thought it wasn't allowing me to drop the local temporary tables between query runs, but now I think it was:
1. I forgot a drop table statement or two, followed by
 
Is there any way to find out which objects havent been released? Or do I have to manually find them in my code?
 
2. My failsafe if object_id('tempdb..#temptable') is not null drop table #temptable; clauses weren't working as I expected.
I thought those clauses would catch me if anything wasn't dropped.
 
Nevermind, excel.quit does the trick
 
7:03 PM
Do array declarations have to have a type? I tried using Array data = .... but then when I went to retrieve values like data(i, j) I got method expected
 
VBA?
 
oh
 
I am unlikely to need VBA help lol
 
that's int[x,y]
 
7:05 PM
What if I am loading a table of strings and ints into an array?
 
then you're F'd
 
Do I have to just convert it all to string and convert to int if I need the int?
 
might as well just box the ints into an object - make an object[,] array
 
Every time I begin to think I may like C# you throw crap like this at me
6
 
probably an array isn't the right data structure for this
would the strings happen to be keys?
 
7:07 PM
Kind of
 
..
 
^ haha
 
In VBA I would convert it into multiple dictionary subsets
 
then you can kind of use a Dictionary<string, int>
 
and then I would collect them together based on specific keys, and then use a dict from there
but the problem is, I usually use something like Dict key, value()
where value is an array
and there is a header dictionary with indexes for columns
 
7:08 PM
it looks like you need a proper type
 
No babysteps then
 
well, when data structures get messy and the number of angle brackets gets out of control, I usually take it as a sign
(other times I just roll with it)
 
A sign that I should be using a database? My life would be much easier lol
Then again, my job likely wouldnt be needed
 
I'm just too foggy on what your data looks like to be of any help I think
and unless he messes everything up, this guy is getting a 100.... and then will fail to understand what he's copying, and then next work will score half of that
0
Q: VBA do loop issue

alexredskisn96I am trying to finish a school project. It is using a Userform and asking for inputs to create a sandwich. My problem is I cannot get a variable to go up by one after the loop has been done once. Every time the user enters a sub, I want the userform to go back to empty, and their selections to b...

@alexredskisn96 thanks for the checkmark - please make sure you ask if you have any question about it: it's more important that you fully understand what's going on than this program works. — Mat's Mug 6 secs ago
was fun though
 
I'm working with something like this where I need to group everything by the second field, then the first field, third, fourth, and then contain the entire row of data underneath that
 
7:18 PM
okay. wow.
 
So retrieval would be something like BRU > 08EW1 > ID > SECTION
Yeah
 
screw dictionaries and arrays.
 
I have a class I use for it in VBA
but nothing for C#
But I need to do this on all of them, not just one person
 
make a class for the lowest granularity level of data
you'll want to work with an IEnumerable<ThatClass>
and then let some LINQ do the groupings
 
So make properties for each row essentially?
 
7:19 PM
column
 
Well yeah
But group into classes by row
 
so each row is an instance of that class
 
Why can't C# just have user-friendly arrays?
 
because you don't know LINQ?
 
Cause sometimes I am dealing with 60,000 records at a time
And I dont know LINQ lol
and I dont want to make a class and properties for this one report lol
Because a good number of these records would be disposed as soon as the user selects what group they want to target
 
7:21 PM
var data  = records.GroupBy(item => item.Something).ToDictionary(g => g.Key, g.AsEnumerable());
or with an anonymous type:
var data = records.GroupBy(item => new { Foo = item.Foo, Bar = item.Bar }).Whatever
 
Though, in fairness that would provide some flexibility in the output. In theory, I could just retain all of the records in memory, and they could get dynamic inputs without needing to run separate instances of the report.
My only problem with that approach is that it works for this report. But the report I more frequently use has 110+ columns
Theres no way I am defining 110+ individual properties
 
that's... rather abusive
 
Its all valuable data, but yeah
 
there's no way anyone is looking at 110+ columns
 
You would be surprised
 
7:24 PM
that report tries to answer all questions at once
 
Legitimately
 
yeah, I know the drill
 
It is a one size fits all kind of report lol
 
my job title is Business Intelligence Specialist
 
Which is also why my job exists
Explains a lot lol
 
7:25 PM
:)
 
@Mat'sMug I take it once one understands LINQ new possibilities open up?
 
Once you understand delegates and anonymous types, programming will never be the same
 
I'm just getting to the point of being able to understand anonymous types
 
Im just trying to get to the point of understanding C# lol
 
Linq is just leveraging that to let you query the data that's in your code
 
7:30 PM
@BrandonBarney I read that line and thought "If they are going to be thrown away make them anonymous."
@BrandonBarney As am I.
 
I dont know what the anonymous part means
I barely know how to create them
 
var anon = new { Foo = 42, Bar = "Hello" };
 
^^ AFAIK it's because they aren't declared anywhere other than new { <stuff> }
 
In VBA I would just do array = pivottable(1).TablesRange1.Value
 
The compiler creates a nameless class with int Foo and string Bar members
 
7:32 PM
So anonymous variables basically are just used to insert into something, and then immediately dont exist within that context? (outside of the collection they get put into)
 
You can't pass them around, so they're best used in inline functions
/delegates
 
Makes more sense now
 
This is the best part about the RD team and @Mat'sMug.
They are willing to help you help yourself by assisting your learning.
 
Yeah, if it wasnt for this chatroom I likely wouldve given up on C#
 
They see you trying to grab the spoon and slowly nudge it closer to you so you can pick it up.
@BrandonBarney As I probably said earlier "Welcome to the pond."
 
7:35 PM
*Bathtub :p
 
eh, I'm just doing this selfishly so that RD gets more contributors and I can take a break lol
(not really)
 
Im fine with working on a project once I learn C#. Itll help in many ways
 
My goals to help @Mat'sMug for all the help he's given me and contribute back to RD.
 
What about converting the data into a set of lookups where the lowest dimension becomes the lowest dimension in the lookup? So same structure as before, but I just need to determine how to get the values of the lowest lookup into the lookup as a row.
But that comes with the type conversion problem (on other projects)
 
is the data coming from SQL Server?
 
7:40 PM
Though I would have to create and hold onto n collections where n is the number of hierarchies I need. Nevermind.
Yes, but I dont have access to it.
 
SQL Standard?
 
And I wont for a year minimum.
 
oh
I bet the 100+ columns have things like CustomerCode, CustomerName, CustomerAddress1, CustomerAddress2, CustomerAddress3, CustomerCountry, CustomerState, CustomerCity, etc... right?
 
A couple of those yes, but mostly flags and calculated things like "Grade Average" and "At Risk" stuff like that
 
80-some flags and other measurables???
 
7:43 PM
So about half of them are neccesary for daily reporting, and the other half are for slicing
 
hi @alexredskisn96!
hi F5 to reload the page if you want to talk, I granted you explicit write access
 
Of the 110 I would say I reliably capture 30-40ish per report I automate
 
this soooooo looks like a job for SSAS
 
We have that for other reports
 
so you do have cubes set up?
 
7:45 PM
Its just that the people in charge of that side are overloaded, and new management is coming in
Yes, but for other data sets
Not this stuff
 
ah
 
@alexredskisn96 Welcome to the pond.
 
And they are amazing
But, only helpful when I need that data
 
I'd take the hit and make that 110-property class
all auto-properties, can't be too painful
 
Plus, the majority of the reports I do are at the individual level, so the actual person, whereas the cubes are for the aggregates
 
7:46 PM
I just lost 90 minutes of my life.
 
Auto properties?
 
public int Foo { get; set; }
public string Bar { get; set; }
@Hosch250 what happened?
 
Still requires typing and setting though right?
And I would need a way to identify the column I am working with
Ill probably end up doing it but sheesh lol
 
yeah but then you're golden, and Visual Studio will literally tell you which columns (properties) aren't used anywhere
well, I think
with ReSharper anyway
 
Dont have resharper. But I mean getting the value out of the table itself.
Instead of using foo = range(1)
 
7:49 PM
that's easy as pie
 
your source is SQL Server right?
or some Excel table?
 
Excel tables generally
 
properly formatted as tables, and with consistent data types?
 
7:50 PM
good
excellent
 
I didn't know I was going to have to take a full-blown IQ test for a developer position.
 
connect to them through an ODBC connection string
 
Connect to the table itself?
 
Figuring out picture patterns, alphabet patterns, you name it.
I'm dizzy.
 
7:51 PM
@Hosch250 some places also make you pass a personality test
@BrandonBarney yes
 
@Mat'sMug This was one of them.
79 questions of them.
 
aye, nothing special there :)
went well?
 
I failed pretty hard on the math--I've not done algebra or statistics for a few years.
 
Ill check out ODBC connections then and see how that goes
 
And I'm pretty good at math, as a general rule.
On the other hand, Robert Half just called right when you pinged me, and they have a fourth position for me to interview for.
 
7:52 PM
@BrandonBarney look into Linq-to-SQL
 
I'll be happy to skip that previous job.
 
Will do!
 
ideally you would just connect to the SQL Server source
and use Entity Framework
 
I gladly would lol
 
They said I'll probably have an offer on Tuesday from the first company, and an interview on Wednesday from another, with a potential offer there.
 
7:53 PM
not sure EF can work with an ODBC source
@Hosch250 at this rate you'll be interviewing companies soon :)
 
Heading out for the day, see yall tomorrow
 
but anyway the idea is that you map columns from the source to properties in your class
 
Thanks for all the help
 
np
cheers!
 
8:06 PM
@Hosch250 Keep at it.
 
@Mat'sMug Hi thanks for adding me! I also saw your response to my question - I have not had a chance to fully implement it, but I do understand mostly what is going on. (I didn't know at the time a check meant an answer - indicated it worked). I appreciate your response
 
Anyone here ever hear of or use LINQPad?
 
@IvenBach lots of people use it... I don't.
@alexredskisn96 hey no problem
 
I'm just reading more regarding LINQ and stumbled onto it.
 
useful for quick-n-dirty trying stuff
oh, since you're getting into LINQ - there's 2 syntaxes: method syntax, and query syntax. stick to method syntax for now :)
@alexredskisn96 tried Rubberduck yet?
 
8:17 PM
@IvenBach Sometimes.
 
query syntax is easier for me to understand.
 
Query syntax is a pain.
 
@IvenBach sure, but if it's making you think in SQL then it's wrong
 
I have no SQL experience so no worry about that.
I've only ever done a tiny bit of Microsoft Access and that's how I understood what it was doing.
 
also query syntax becomes very painful once you start grouping things
 
8:19 PM
Method syntax takes me a lot longer to process.
The ( n => n) stuff messes with me, really bad.
 
just know that whenever you see a =>, you're looking at a function that operates on every item in the collection
 
@Hosch250 Good luck and congratulations! But stay wary about what Robert Half is telling you - my experience with recruiting companies is they want you to think they're being a big help and everything is great, but it doesn't always work out. Pretend like everything's normal until you have paper in your hand.
 
@Mat'sMug and the ( x => x) is just grabbing every element/item?
 
yeah.... IOW x => x is essentially no-op (assuming Select here?)
if x is a bool, then you could have .Where(x => x) and the result would be all elements that are true
 
no-op = no operation?
 
8:26 PM
well, .Select(x => x) gives you an IEnumerable<whateverthetypeofX>, so yeah, nothing done
BTW LINQ stands for Language-INtegrated Query, so it's for querying data: none of it should have any side-effects, ever.
 
Laymans terms: It shouldn't change the source data in any way?
 
exactly
or anything external to the query either
 
:+1: Man this is scary, I'm actually learning this stuff.
 
scraping the surface, really
 
#GottaStartSomewhere
 
8:31 PM
^
go ahead and play with it
 
The stuff I'm learning has been all sorts of frustration for a very long time. Just knowing I'm teaching myself the basic building blocks gives me confidence that "Yes I Can. YES I CAN!"
 
all you need is using System.Linq and then any IEnumerable<T> can be queried
 
#NuttyProfessor
Laying down the foundation on which to learn was so mind-boggling. Now that a tiny corner has been set up I know where to start from.
 
soon you'll realize that a lot of foreach loops you write, can be expressed as a LINQ query
oops I think I just spoiled it
 
You're one of those dads whose kids found out early about Santa, aren't you?
 
8:37 PM
kids are turning 5 tomorrow (twins), haven't killed Santa.... yet.
wow, exactly at this time 5 years ago I was speeding home back from work after a phone call
"they're coming!"
 
@Mat'sMug I already saw that the moment I understood what LINQ is.
 
:)
 
@puzzlepiece87 Santa == Jolly fatman when you left him a beer for Christmas.
That's what my dad taught me from a young age.
@Mat'sMug Time flies fast.
 
it does
 
What's the consensus on Method Chaining?
 
8:41 PM
keep it readable
LINQ method syntax is meant to be chained
I tend to chain and nest too much
 
@Mat'sMug Spend all the time you can with your kids. It'll make a big difference when they're older and can talk to you about anything.
 
yeah
 
So long as it's readable there's no need to create intermediary variables. Because those intermediaries have their methods invoked until results are achieved?
 
@Mat'sMug Congrats on the milestone.
 
@puzzlepiece87 I survived twins for 5 years? or they survived me for 5 years?
@IvenBach that's the beauty of LINQ: nothing gets invoked until the results are iterated
some methods, like ToList or ToArray, or ToDictionary, or Count, materialize the query on the spot
but every Select, Where, GroupBy, ... only actually gets invoked when the results are iterated
that's quite a crucial thing to keep in mind
especially if you're coding against Entity Framework and your LINQ gets translated to SQL statements that hit the database
^ that's right. no more in-code SQL strings. ever.
 
8:46 PM
So use someList.ToString().ToString().ToString() instead of ....
 
uh, ToString is a member of System.Object
I was referring to the LINQ extension methods
 
var firstString = someList.ToString()
var secondString = firstString.ToString()
var thirdString = secondString.ToString()
I can't recall any method other than ToString()
MSDN appears to be down
If I were to have used a valid LINQ method in place of ToString()
 
var activeThings = things.Where(foo => foo.IsActive);
var blueThings = things.Where(foo => foo.IsBlue);
var allThings = activeThings.Concat(blueThings).ToList();
the type of activeThings and blueThings if you hover var, should be IQueryable<something>
IQueryable<T> is what enables LINQ's deferred execution
 
var allThings = things.where(foo => foo.IsActive).Concat(things.Where(foo => foo.IsBlue)).ToList();
Is that the kind of chaining that shouldn't be done and separated out as is your example?
 
depends. as a one-liner, I'd cringe. but then...
nah, nested. I'd cringe.
 
8:52 PM
Ok. That was my main question.
 
(I'm actually guilty of that... a lot. ask @Hosch250)
 
RoT (Rule of Thumb): do at worst 1 => per inline?
 
            var fields = State.DeclarationFinder.UserDeclarations(DeclarationType.Variable)
                .Where(item => !IsIgnoringInspectionResultFor(item, AnnotationName)
                               && item.Accessibility == Accessibility.Public
                               && (control == null || !Equals(item.AsTypeDeclaration, control)))
                .ToList();

            return fields
                .Select(issue => new EncapsulatePublicFieldInspectionResult(this, issue))
                .ToList();
@IvenBach yeah, and line them up vertically.
 
Ok. I know RoT can be broken in certain instances but in general should be held to.
 
hmm, that first .ToList shouldn't be there.
can you tell me why?
 
8:59 PM
It's converting it again to a list in the return fields instruction?
I'm not entirely sure?
 
when does the query get materialized?
and how many times?
 
This is pure guess: Any time.ToList() is found?
I know you said it's run when a foreach is executed.
But since I one isn't in the code you gave I've no idea.
 
@IvenBach no, I said when the query results get iterated - and then
19 mins ago, by Mat's Mug
some methods, like ToList or ToArray, or ToDictionary, or Count, materialize the query on the spot
so your guess is correct. twice is the answer.
 
@Mat'sMug I misunderstood this to just mean foreach
Duh Check: Does that mean that a foreach iterates over every element within the IEnumerable<T> or IEnumerable?
 
the real answer to that question is much more interesting than what you'd think: it's neither.
foreach has a rather interesting implementation
 
9:08 PM
2 hours ago, by Brandon Barney
Every time I begin to think I may like C# you throw crap like this at me
 
it looks like it works off any IEnumerable (and does), but in fact it's not even checking for the interface
 
~.~ I really need to read over the operators page like @Hosch250 told me to so I can pretend to know a little bit more.
 
@IvenBach Don't just read it--use them.
Yeah, foreach will work on any type that exposes a method with a certain signature.
I don't remember offhand, but I think it is T GetNext<T>(), or something.
 
@Hosch250 nope, it predates generics
 
OK, just plain old {type} GetNext()?
 
9:12 PM
simple-talk.com/wp-content/uploads/2017/04/… good to come back to once I've understood more regarding LINQ?
 
IIRC the method is the same that IEnumerable imposes, so Enumerator GetEnumerator
 
Oh, I see.
 
might be wrong though
 
@Hosch250 As I read the pages I go through them with examples I come up with to make sure I'm understanding.
 
@Mat'sMug I would say anyone that has survived being a parent for years with their kids' bodily integrity, mental integrity, and sense of decency intact is probably a good parent :)
Parenting is hard
 
9:15 PM
lol
MY EYES!!!!! THEY IZ DOOOOMED!!! — user00001 24 secs ago
takes some nerve to ping a moderator with such a comment.. I'll just leave it there unless it gets flagged though
@puzzlepiece87 thanks!
 
It looks like it is E GetEnumerator() where E exposes a T MoveNext().
@Mat'sMug It's no different than any other comment.
 
IMO it's flaggable as too chatty
 
So are 99% of the comments on the site.
 
10:16 PM
@Mat'sMug are responses like that automated for moderators while they are in chatrooms?
 
Huh?
it's just a regular ping :-)
TTGH
 
letting you know there was a response to one of your questions?
Be safe getting home
 
10:48 PM
> The code below results in 3 errors

1. Return value for member 'Bar' is never assigned
2. Variable 'list' is used but not assigned
3. Variable 'list' is never assigned

```
Public Sub Foo()
Dim list As Range
Set list = Bar
list.Value2 = "foo"
End Sub
Private Function Bar() As Range
Set Bar = Sheet1.Range("A1")
End Function
```
 
11:05 PM
Does overflow occur much with variables? I'm reading about the checked keyword right now.
 
It can.
 
Just be cognizant of that fact?
 
You don't need that too often, but there certainly are cases when you should use it.
 
11:33 PM
bitwise compliment operator ~ used much?
0123456789ABCDEF  // bit
FEDCBA9876543210 // compliment
 
Sometimes.
 
I'll probably have questions along these lines till I finish with the operators.
 
Pretty often in some specialized applications.
 
So long as I'm aware of it and can do it I'll keep progressing.
 
00:00 - 18:0018:00 - 00:00

« first day (1056 days earlier)      last day (2124 days later) »