[dba-VB] VB.Net stuff

John W. Colby jcolby at ColbyConsulting.com
Mon Mar 17 14:35:54 CST 2003


Boy would I agree with THAT.  It is much more of a pain to learn exactly
because of the new inheritance stuff.  But the key here is that the .net
framework is a prewritten set of classes and class trees that expose a TON
of functionality that is just waiting to be used.  According to the "sales
pitch" stuff the compilers are actually a thin layer over the .net
framework.  Only the truly language specific keywords are in the compiler.
Everything else is a class.  

Even VARIABLES are classes, complete with methods and stuff.  Weird!  But
once you start to understand it it all starts making sense and becomes
extremely powerful.  Because the variables are classes (strings, longs,
singles etc) they are all expressed and used identically from language to
language.  No more page faults because you tried to pass the wrong thing to
something originally written in C.  C is using exactly the same class for a
string as you are in VB as the next guy is in J etc.  This really does free
up the dev TEAM to use whatever they prefer rather than have it dictated to
them by management.

John W. Colby
Colby Consulting
www.ColbyConsulting.com

-----Original Message-----
From: dba-vb-admin at databaseadvisors.com
[mailto:dba-vb-admin at databaseadvisors.com]On Behalf Of Jim DeMarco
Sent: Monday, March 17, 2003 1:30 PM
To: dba-vb at databaseadvisors.com
Subject: RE: [dba-VB] VB.Net stuff


Great observation Joe and pretty true.  That was my first take too
(Java-like) although as powerful as .NET is it is more complicated than good
ole VB6 (maybe complex is a better word for it).  I consider VB 6 an easy to
use and easy to learn language and development environment.  I think M$
complicated it a bit especially where OOP is concerned.  Yes, it has all the
things a developer who uses object oriented techniques wants but I think it
might make it a bit complicated for a newbie or junior developer.

Not to say it's not a great tool.  The IDE is great and it really is a
powerful tool not to mention the server explorer and datasets/datatables as
John mentioned.  It just seems somewhat harder to learn than classic VB.

Jim DeMarco
Director of Product Development
HealthSource/Hudson Health Plan


-----Original Message-----
From: Joe Rojas [mailto:JRojas at tnco-inc.com]
Sent: Monday, March 17, 2003 1:23 PM
To: 'dba-vb at databaseadvisors.com'
Subject: RE: [dba-VB] VB.Net stuff


John,

Looking at the couple of coding examples that you have posted, both here and
on the AccessD list, I keep getting this feeling that I am reading Java
code. :-)
A lot of the keywords, and their uses, look exactly the same as Java and I
would assume that they work the same too. This sounds promising for the .Net
platform because Java is very cool, IMO!

Your excitement towards VB.Net reminds me of how I felt when I started
learning Java. My ignorance of the whole .Net stuff made me skeptical about
it, but it sounds like it is worth a look!

I really enjoy your updates that you post as you learn VB.Net, I find them
very useful!

-Joe

		 -----Original Message-----
		From: 	John W. Colby [mailto:jcolby at colbyconsulting.com] 
		Sent:	Saturday, March 15, 2003 9:24 AM
		To:	dba-vb at databaseadvisors.com
		Subject:	RE: [dba-VB] VB.Net stuff

		Jim,

		I am reading Programming Visual Basic .Net by Francesco
Balena - ISBN 0-7356-1375-3.  Given that it is the only book on the subject
I have I can't compare it to anything but it has done a good job of
explaining the basics so far.  It does assume that you are a VB6 programmer
(which I am not) and know that pretty well, so if you have no VB experience
it might be an even steeper learning curve.  OTOH, so much has changed from
VB (apparently) that I am not even sure how important it is to know that
stuff.  Apparently the dev environment is completely different, the language
now has true implementation inheritance (inherits the functionality and
interface instead of just the interface) and is really just a thin layer
over the .Net framework of a few thousand classes and interfaces.

		Implements is a keyword that tells the compiler that you are
implementing an interface.  Interfaces are still useful in cases where the
actual implementation is so specific to what you are doing that trying to
inherit code wouldn't be helpful, yet you still want to define a standard
interface so everyone does things the same way.  IEnumerable is an interface
for enumeration, which of course is the process of enumerating a set of
objects, handing back one object every time you are called.  The hard disk
makes a good example, the class initializes, starts to read the dir
structure and file names.  Each time the class is called, it finds the next
directory / file and hands back some property or property (a string in this
case with the name of the file).  The class keeps track of where it is in
the disk structure so that the next time it is called it knows where to go
(into subdirectories for example) to get the next file property.

		.Net the framework is a truly awesome collection of classes
that wrap the entire windows API, as well as classes which build up other
useful functionality.  There are collection classes, which are subclassed to
make stacks and queues.  Need a stack?  It's in there.  Need a stack that
does something special?  Inherit it and implement your own custom
functionality.

		There are classes for encryption, literally perhaps 50 lines
of code to open a file (a class), feed the text stream to the encryption
class, feed the encryption stream to a class that transmits the stream out
over the internet.

		Let's not pretend that I have any idea how to do this yet,
but I know that these classes exist.  and with true inheritance, tweaking
existing stuff to do what you need has to be a bajillion times faster that
writing it yourself from the ground up.

		Of course you have to learn the namespaces and where all
this stuff is, as well as how to use the individual classes once you know
where they are.  

		John W. Colby
		Colby Consulting
		www.ColbyConsulting.com

		-----Original Message-----
		From: dba-vb-admin at databaseadvisors.com
		[mailto:dba-vb-admin at databaseadvisors.com]On Behalf Of Jim
Lawrence
		(AccessD)
		Sent: Saturday, March 15, 2003 2:23 AM
		To: dba-vb at databaseadvisors.com
		Subject: RE: [dba-VB] VB.Net stuff


		Hi John:

		Looks like awesome stuff. I have been wandering around the
side of the .net
		pool for a while and will eventually have to jump in...but
learning this
		coding will be like climbing 3000 vertical feet with two
pack-sacks on. What
		is a 'Implements IEnumerable' anyway? Modules? Classes and
internal
		sub-classes with functions and subroutines floating around?
This looks like
		something that will take more than an evening to master. 8-/
I bet there is
		no books that will read 'Master .Net in 24 hours'.

		Nothing like a good challenge...:-) Any recommendations for
a good book to
		start?

		Jim

		-----Original Message-----
		From: dba-vb-admin at databaseadvisors.com
		[mailto:dba-vb-admin at databaseadvisors.com]On Behalf Of John
W. Colby
		Sent: Friday, March 14, 2003 5:41 PM
		To: AccessD
		Cc: VbAdmin; VBA
		Subject: [dba-VB] VB.Net stuff


		I thought you folks might be interested in looking at some
of the features
		that .net exposes.  The following is a class directly from
"Programming
		VB.net" by Francesco Balena.  It is fascinating (to me
anyway) as it clearly
		displays the usage of a whole slew of functionality built in
to the .net
		environment.  It was really an exercise in demonstrating the
ability to add
		enumerators to any class (where appropriate) so that people
using your class
		could use "for each" constructs with your classes.

		This class iterates a disk path and returns the file name of
each file or
		directory in turn.  Please let's not get in to a "it could
have been so much
		simpler".  I have no idea whether that is true, and really
don't much care.
		In fact I don't even understand all that is happening here!
I am simply
		showing the code so that anyone who is interested can see
how the author
		uses built in classes such as IEnumerator, and the built in
stack class of
		the Systems.Collection namespace.  Seriously cool built in
functionality
		ready to be built upon.

		I built a wrapper function:

		Module Module1
		    Function TestGetEnumerator(ByVal strRoot As String) As
String
		        Dim f As System.IO.FileInfo
		        Dim str As String
		        'enumerate all files in strRoot  directory tree
		        For Each f In New FileTree(strRoot)
		            str = str & f.FullName & vbCrLf
		        Next
		        TestGetEnumerator = str
		    End Function
		End Module

		Which I then used in the OnOpen event of a form to return a
string of all
		the files and directories in a given path (hard coded),
which I then place
		into a text box on a form.  What I want to do is have the
function be the
		datasource for a combo or list but I couldn't figure that
out and needed to
		move on.  ;-)

		The result is an EXE which I could mail to you which opens
the form and
		displays the file names.  Of course I can just as easily use
the file name
		to do some processing on that file, likewise the class could
be modified to
		return any of the file attributes - size, created date etc.

		The EXE is ~10k but of course requires that you have the
.net environment on
		your computer.  Anyone that uses the Windows Update feature
to keep their
		system up to date with all of the latest patches has
probably been offered
		the ability to download and install the .net environment
needed to run my
		10k exe.

		Anyway, the class is as follows - all copyrights belong to
their owners, not
		me.

		Public Class FileTree
		    Implements IEnumerable
		    'The search Path
		    Public ReadOnly DirPath As String

		    'The constructor
		    Sub New(ByVal DirPath As String)
		        Me.DirPath = DirPath
		    End Sub

		    'Return an enumeraable object(an instance of the inner
class)
		    Function GetEnumerator() As IEnumerator _
		        Implements IEnumerable.GetEnumerator
		        Return New FileTreeEnumerator(DirPath)
		    End Function

		    'The IEnumerator private object
		    Class FileTreeEnumerator
		        Implements IEnumerator
		        Dim DirPath As String

		        'This variable contains the Enumerator object for
the file list
		        'in the dir being scanned
		        Dim FileEnumerator As IEnumerator
		        'This variable contains the stack of the Enumerator
objects
		        'for subdirs of all pending directories
		        Dim DirEnumerators As New System.Collections.Stack()

		        'a simple constructor
		        Sub New(ByVal DirPath As String)
		            'Save the dir path
		            Me.DirPath = DirPath
		            'manually call the reset method
		            Reset()
		        End Sub

		        Sub Reset() Implements IEnumerator.Reset
		            'The dir object that represents the root object
		            Dim di As New System.IO.DirectoryInfo(DirPath)

		            'get the Enumerator object for the file list,
and reset it
		            FileEnumerator = di.GetFiles.GetEnumerator
		            FileEnumerator.Reset()

		            'get the enumerator object for the subdirectory
list
		            Dim dirEnum As IEnumerator =
di.GetDirectories.GetEnumerator
		            dirEnum.Reset()
		            'push it onto the stack
		            DirEnumerators.Push(dirEnum)
		        End Sub
		        Function MoveNext() As Boolean Implements
IEnumerator.MoveNext
		            'simply delegate to the file enumerator object
		            If FileEnumerator.MoveNext Then
		                'it returned true so we can exit
		                Return True
		            End If

		            'if there are no files in the current directory,
check
		            'for another subdirectory in the cuurrent
directory
		            Dim dirEnum As IEnumerator = _
		                CType(DirEnumerators.Peek, IEnumerator)
		            'check whether current subdirectory enumerator
has more items
		            Do Until dirEnum.MoveNext
		                'There are no more subdirectories on this
level
		                'so we must pop another element of the stack
		                DirEnumerators.Pop()
		                If DirEnumerators.Count = 0 Then
		                    'return false if no more subdirectories
to scan
		                    Return False
		                End If
		                'get the current enumerator
		                dirEnum = CType(DirEnumerators.Peek,
IEnumerator)
		            Loop

		            'We can create a DirectoryInfo.
		            Dim di As System.IO.DirectoryInfo = _
		                CType(dirEnum.Current,
System.IO.DirectoryInfo)

		            'Store the file enumerator and reset it
		            FileEnumerator = di.GetFiles.GetEnumerator
		            FileEnumerator.Reset()
		            'Get the enumerator for the subdir list
		            'and reset it
		            dirEnum = di.GetDirectories.GetEnumerator
		            dirEnum.Reset()
		            'push it onto the stack
		            DirEnumerators.Push(dirEnum)
		            'recursive call to process the file enumerator
		            Return Me.MoveNext
		        End Function

		        'The current property simply delegates to
FileEnumerator.Current
		        ReadOnly Property Current() As Object Implements
IEnumerator.Current
		            Get
		                Return FileEnumerator.Current
		            End Get
		        End Property
		    End Class

		End Class


		John W. Colby
		Colby Consulting
		www.ColbyConsulting.com

		----------------------------------------------------
		Is email taking over your day?  Manage your time with
eMailBoss.
		Try it free!  http://www.eMailBoss.com


		_______________________________________________
		dba-VB mailing list
		dba-VB at databaseadvisors.com
		http://databaseadvisors.com/mailman/listinfo/dba-vb
		http://www.databaseadvisors.com

		_______________________________________________
		dba-VB mailing list
		dba-VB at databaseadvisors.com
		http://databaseadvisors.com/mailman/listinfo/dba-vb
		http://www.databaseadvisors.com




		----------------------------------------------------
		Is email taking over your day?  Manage your time with
eMailBoss.  
		Try it free!  http://www.eMailBoss.com



This electronic transmission is strictly confidential to TNCO, Inc. and
intended solely for the addressee. It may contain information which is
covered by legal, professional, or other privileges. If you are not the
intended addressee, or someone authorized by the intended addressee to
receive transmissions on behalf of the addressee, you must not retain,
disclose in any form, copy, or take any action in reliance on this
transmission. If you have received this transmission in error, please notify
the sender as soon as possible and destroy this message. While TNCO, Inc.
uses virus protection, the recipient should check this email and any
attachments for the presence of viruses. TNCO, Inc. accepts no liability for
any damage caused by any virus transmitted by this email.
_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com



****************************************************************************
*******
"This electronic message is intended to be for the use only of the named
recipient, and may contain information from HealthSource/Hudson Health Plan
(HS/HHP) that is confidential or privileged.  If you are not the intended
recipient, you are hereby notified that any disclosure, copying,
distribution or use of the contents of this message is strictly prohibited.
If you have received this message in error or are not the named recipient,
please notify us immediately, either by contacting the sender at the
electronic mail address noted above or calling HS/HHP at (914) 631-1611. If
you are not the intended recipient, please do not forward this email to
anyone, and delete and destroy all copies of this message.  Thank You".
****************************************************************************
*******

_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com




----------------------------------------------------
Is email taking over your day?  Manage your time with eMailBoss.  
Try it free!  http://www.eMailBoss.com

----------------------------------------------------
Is email taking over your day?  Manage your time with eMailBoss.  
Try it free!  http://www.eMailBoss.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 9352 bytes
Desc: not available
URL: <http://databaseadvisors.com/pipermail/dba-vb/attachments/20030317/fd34a0e3/attachment-0003.bin>


More information about the dba-VB mailing list