Am 04.01.2011 09:33, schrieb Cor:
I'm not
direct like Armin(the first time I saw his replies I thought he was a kind
of East German Policeman (I've been often in the DDR))
Maybe because I sometimes find the right words in the dictionary, but putting
them together gives sometimes a different meaning or a different impression than it
was actually meant. (I _still_ don't understand why "please turn to group XY"
is considered impolite... I said "please" ^^ I'll never forget this.).
I know I sometimes articulate intricately, but as I'm also not a native English
speaker, you know, and I have never lived in an English speaking country, I'm
trying hard.
Now we have Option Infer
which makes Option Strict Off in fact not so much needed anymore. Option
Infer is standard default On. It looks to the signature of the data you use
in a declaration and defines than fixed the type of the data at design time
(the name of that is strongly typing). In C# it is named Asynchronous type
but in fact it is the type which is inferred in VB at Dim. C# has in version
2010 by the way also the Option Strict way. To say it in VB6 words, option
strict off can results in a kind of variant type which gives errors for
instance if that is seen as a string while you are calculating (in C# 2010
the keyword is for the VB6 variant "dynamic" the interfered dim is named in
C# the Var), the VB6 Variant does not exist anymore in VB for Net. To be
before Armin, Infer does not work on global level only inside a method,
while option strict off does.
Well, (you knew I will answer this, huh?) it's less the variable type, it's more
that accessing none-existing members must not work (as I said with few exceptions
like Office Automation).
I think I write to much so I stop.
Hey, it's ok, we must produce some traffic here!
Saying this, I keep on doing so...:
(I'm mainly talking to Mr. StrandElectric here, trying to do convincing.)
Let's start with classes, the main building brick. Anyone says that they should
be cancelled? In don't think so. It was always a programmer's need to put associated
data together (also like UDTs), so why not call them "classes"!? Then came
OOP and we've put the code also into the class. It makes sense for known reasons.
Then we have Structures/UDTs. Almost the same, just a different memory management
and what we can do with them, so usable in other situations. I rarely write
them because I know from experience that I _will_ want to set a reference to the
object later (other than ByRef).
Do we still agree with these basics?
Overview gets lost the more classes we have. To avoid this, we (at least I) always
feel the need to arrange things. Voilá, we have namespaces. Thanks for them. That's
all necessary to say about them. Just open the object browser, look at the Framework
classes grouped by namespace, and you'll see it. At the latest if you start counting
the classes, you will understand why namespaces make a lot of sense.
That's the whole structure of the "type system" explained. Uhm, almost, but everything
further doesn't change the "big picture". Done.
Sure, there are more things, like "inheritance" and "interfaces". Right, we could do at
least without one of them, but they came from the practical programming requirements
saying "this is like that" or "this must match that". It's a programming pattern or way
of thinking that programmers came across very frequently. So, wouldn't it be nice if the
language would support this? Don't worry, I won't elaborate on the two terms in detail.
That's been done a million times. If you don't understand their usefulness, just leave it.
Really, then I'm running out of arguments. Your problem then.
So, this chapter one was about the concept. VB is a multi-purpose language that implements
this concept. No Printer object here, right? Absolutely, this is the reason: VB is a
multi-purpose language - I must repeat this - and therefore it does not have a built-in
Printer object. Where should it be? There is not place for it "in the language". The
language has keywords and a syntax and whatever. It is a tool for using existing code and
creating new code.
Chapter II is the .Net Framework class library. The class library is the "existing code"
part from the last sentence in the previous paragraph. _That_ is the place where a
Printer object/class _could_ be located. The class library is a huge collection of classes
etc that we can make use of. Don't forget that VB6 had to use references (even to
VB/VBRUN/VBA) to be able to do basic things, too.
There are some namespaces in the Framework class library that start with "Microsoft.VisualBasic".
But this does not mean, they can only be used from VB.Net. As they meet the same standard
as all other libs, they could be used from any other language, too. If you look at them,
you'll notice that most things are dispensable. Why? a) Because some parts are only for
people that are unable to find the straight way in the rest of the Framework, or for
nostalgic reasons. BTW, I'm still using "Msgbox" instaed of "Messagebox.Show" because I'm
used to it and I don't care, but that's probably the only old-style function I use from
there. b) Other parts are newer and support something that I call My.Crap. Not elaborating
on this, too.
Conclusion: the whole thing about learning VB.Net is understanding the two main parts:
The _common_ type system (common to multiple un-isolated langauges) on one hand, and getting
into the .Net Framework class library on the other hand.
Maybe you can make a suggestion at
https://connect.microsoft.com/VisualStudio/Feedback
and ask them to implement the VB6-style printer object in the next version of the Framework.
By then, you must be satisfied with what is currently offered, namely the PrintDocument class.
The common language specification has been built from scratch (of course with many
influences and experiences from wherever) to come up with the requirements of nowadays
programming. VB.Net is one implementation of that standard with many language characteristics
(keywords) well-known from previous versions. If you don't understand the new concept, you
won't get along with VB.Net very well.