these lines at
the top of the
source code file...
some data to the
a standard "DoEvents"
for 2 seconds
you can see above, it looks a lot better
now :) Once you've placed the relevent
"Imports" lines at the top of
any given file you can use all of its
functions without having to type the full
"path". Similiar methods exist
in C# and C++. Thankfully, the Intellisense
(Discussed earlier) brings up a list (in
VB) as soon as you type a "."
after the name, so you dont have to learn
all the different sub-objects of each
library - a bit of educated guess work
can still be used!
I've slightly hinted at above, these .Net
frameworks are same in all the languages,
so effectively you only need to learn
".Net" and not a different .Net
for each connected language, this does
give the huge advantage of being able
to jump between languages very easily
once you get used to the software.
has changed, this is probably nothing
new to most of you - news of these changes
isn't anything new (they were announced
at the beginning of VB.Net's development),
and I've already seen plenty of message-board
posts discussing the pro's and con's of
general idea behind the changes appear
to be two-fold. Firstly VB.Net has been
brought completely up-to-date with the
latest and greatest in Object-Orientated-Programming
(OOP), Sure, VB6 had objects, classes
and so on... but that is nothing in comparison
with the fire-power we now possess. Secondly,
VB has been brought into line with the
other languages that make up the .Net
family; this is probably just for convenience
as well as being a requirement of sharing
the same compiler and the same IDE.
Orientated Programming is an amazingly
complex area when taking to its full extent
(you can get some rather large books about
it), but at a simpler level it's really
not that hard to get used to - and once
you've really gotten used to it, you really
start to like it. There are many arguments
that OOP programming is slower and inferior
to "traditional" methods, but
I discard the majority of these comments.
If you overuse OOP methods and use them
in the wrong place/context then of course
it'll be slower - thats just simple logic!
However, if you use them in the right
place at the right time you're fine -
and the comparative "traditional"
code is much more complicated and prone
to errors anyway.
a quick run-through of all the new/great
Inheritance - This is where you can
derive a class from a "base"
class, or several other classes. This
allows you to take a basic class and improve
it and/or customize it without having
to completely rewrite everything. This
alone is exceptionally powerful, with
respect to gaming/multimedia development
it is brilliant. When writing multimedia
applications/games in C++ before I've
always loved using Inheritance to simplify
certain features, and now that we have
it in VB I'm really quite happy! As a
short example, see this code output: here.
Class Constructors - If you've used
classes in the VB6 or VB5 language you'll
be aware that there is a "Class_Initialize"
and a "Class_Terminate" function
built in by default. These functions are
called when the class is created, and
when its destroyed (respectively). Typically
they'll be used to initialise internal
variables / destroy references etc...
They are generally known as Constructors.
VB.Net allows you to define your own constructors,
and combined with polymorphism (see next
entry) they can be extremely powerful
indeed. Being able to customise these
parts of the class allows you to pass
parameters/references and objects to the
class such that it can customise it's
initialisation process accordingly. See
code ouput for an example
Polymorphism - This is an extremely
powerful feature of OOP as well. It appears
in the form of "Overloading",
as you should be aware, declaring a function
to take two "long" parameters,
then attempting to call it using two "Single"
parameters will cause a compilation error
(invalid type). Using overloading you
can define the same function twice - using
the same name, but with different parameters
(types and number). Once you've defined
all of the different variations on a function
you can use it exactly as normal - and
the compiler will decide which function
to call (based on the number and type
of parameters you are using). See this
code output for an example.
are other OOP features that come up here-and-there,
but they all tend to be based on, or associated
with one of the catergories above. In
my opinion, being able to use these features
is almost worth the upgrade alone - as
you can see in the inheritance example
code, it really does simplify how things
OOP is not the only change to the VB language,
there are numerous other little tweaks
and changes that help to speed things
up, and make your life easier. Again,
a quick run down of the main features:
Exception Handling (SEH) - This is
the new error handling, and is effectively
the same as how C++ programmers handle
errors. An "Error" as we're
familiar with is now known as an "Exception",
and we use a Try...Catch...End Try code
structure to catch all our errors. This
takes a bit of getting used to, and I've
not decided whether I prefer it or not
yet. It is however much more "Solid"
- The good old "On Error Resume Next"
mentality cant be used now, which forces
less sloppy code on your part, and the
"On Error Goto..." structure
is effectively replaced, which was my
favourite method - but arguably it did
get a bit messy using lots of labels/Goto
commands. See this
code example for a comparison between
the old and the new methods.
variables / New variable types - Due
to the common runtime / .Net framework
we get access to quite alot of new variables
and objects, far too many to mention here.
The key difference is that some of them
have changed! An "Integer" is
now a "Short" (16 bit signed
variable) and the new "Integer"
is effectively the same as the old "Long"
(32 bit wide signed variable). This gets
a little bit confusing at first, and I've
tended to use the Int16,Int32 and Int64
variable types instead (their names indicate
how big they are), a "long"
in the new language is fairly platform
dependent - such that on a 32bit system
(as most currently are) it'll be 32 bits
wide, however, on the 64 bit servers it'll
become 64 bits wide. The other thing I
am pleased they included is "unsigned"
integers (16,32 and 64bit variations)
- particularly useful when dealing with
bit-shifting and binary-level manipulation
in all forms of multimedia programming.
The other new feature with respect to
variable declaration is only minor, but
is very useful. Previously where we'd
have to do "Dim A as Long" and
then "A = 10" to declare and
initialise our Long to hold the number
10, we can now do "Dim A as Long
= 10", which is quite cool (and something
C/C++ programmers have had since day-1).
maths operators - There are 4 new
operators of particular interest, all
of which inherited from C/C++ programming.
They dont add any functionality to the
language, just provide some shortcuts
for regularly-performed operators. They
are: +=, -=, *=, /=. These take the variable
on the LHS and add the RHS value to it
before storing it back in the LHS variable
(A+=6 is the same as A=A+6). See this
code example for further examples. Oddly
enough, the language hasn't been given
the "++" and "--"
operators from the C language that are
compiler - The compiler is now pretty
much identical to the Visual C++ 6 compiler,
in that you select "Build" and
you get a window pop-up that gives you
a log of how/what it compiled, and any
errors are outputted here (before it fails).
This way you dont have to go through the
rather tedious affair that was VB6 compiling
(if you had errors that is!) where it
just popped up a message box and aborted
compilation. When you get build errors
now they are automatically added to the
"Task List" so you then have
to go about fixing all of the errors and
then re-build the solution so that you
can actually test it. This may seem like
extra hassle, but it is actually a much
more fluent and easy way of compiling
your programs. As well as these changes,
the compiler (and language) enforces much
stricter guidelines on code - all functions
much have opening and closing brackets
(not always necessary in past versions),
and all variables must be properly declared.
general, the new language changes are
a bit difficult to get used to; it really
does feel for the first few days that
you are learning a completely new language.
I've been using VB since version 4 and
consider myself to be a veteran of the
language - I was quite disheartened for
the first few days of using VB.Net that
I had become a complete "newbie"
at a language I've been using for more
than 5 years now. However, once you cut
through the ice and start to get your
head around the new features and new rules
it doesn't feel so bad. I have to say,
apart from using alot of the new pure-code
features, I'm still using VB.Net in much
the same way as I use VB6, ignoring the
.Net framework except for where I have
to, and just getting on with work. That
in itself shows that you can get away
without upgrading "fully" to
start with, but over time I'm sure I'll
start using the .Net framework to more
of it's potential.
C++ hasn't really changed very much; apart
from using the new IDE there are no major
surprises. However, this is to be expected
- the C++ language is defined by ANSI/ISO
guidelines, so Microsoft cant change
the language even if they wanted to! They
can add additional features/libraries
to the language, which is where the .Net
framework fits into everything. Getting
to work with .Net in C++ isn't very difficult
at all, and if you've used it in any of
the other languages (quite likely!) then
it all looks the same...
the only thing that Microsoft can do to
the actual language is add features, they've
obviously added quite a lot. As will be
familiar to any user of Visual C++ 6 there
are a large number of project templates
and "Application Wizards" which
are very useful to have around, particularly
when you're just getting started with
one of the numerous application types.
("C Sharp") is an interesting
addition to the .Net family, Microsoft
decided that they needed to create a whole
new language for the .Net generation,
and this is the end result. The basic
outline it seems, was to create a next-generation
version of C++ by using C++ style syntax
yet having as many benefits from the RAD
tools such as VB. In my opinion, it's
a bit odd really - Having looked through
(and created) a few sample programs it
doesn't come across as anything much more
than a half-way language between C++ and
long as you're designing "proper"
.Net services and applications then C#
is probably the best language to use -
it was designed from the ground up to
use the Common Language Runtime (CLR)
and to make full use of the .Net frameworks.
Whilst the general nature of the .Net
family means that you can do pretty much
anything (for .Net) in any of the languages,
it is a far easier approach to use a language
that was custom designed for it.
this in mind, C# probably wont bother
many games/multimedia developers - its
a perfectly valid language to use, but
given the common grounding in VB and C++
there isn't enough to really warrant using
C# instead. Should you want to, it's not
that hard to learn - anyone with a decent
general programming knowledge will be
fine, and if you've used VB and C++ for
a while then you're set for a rolling
.Net frameworks are designed to be portable
across as many platforms as possible,
and they're also designed so that any
number of languages can be "plugged
in" and make use of the services.
This is a very interesting feature - it'll
allow for many languages to be used fairly
easily all from the same place, and all
in a similiar way - total freedom of language
(as long as you want to use the .Net frameworks
Visual Studio.Net help files list the
following languages as being "in
development", what they'll actually
turn out to be like cant be known yet
- but you may find a favourite of yours
in the list:
Perl, Eiffel, Python, Pascal, Mercury,
Mondrian, Oberon, Salford FTN95 (Fortran),
Smalltalk, Standard ML and Dyalog