Why is VB.NET better than VB ?

  • Thread starter Thread starter Guest
  • Start date Start date
Kevin said:
As long as I have the attention of all you VB.NET experts, let me ask
the question:

How can I make a textbox control so that the user can't edit the text,
without setting the Enabled property to False (I don't want the
contents greyed out)? I did this in VB6 by putting the textbox in a
frame and then disabling the frame. Can't do that in wonderful .NET...

Whatever was wrong with setting the Locked property to True in VB
Classic? The user could still select and copy the text, though.
Anyway, VB.NOT is most definitely *not* better than VB, unless you
count *guaranteed data loss* as an 'advantage' as Micro$haft does:


"So, here is Microsoft's solution: the StreamWriter type doesn't
implement a Finalize method at all. Of course, this means that
forgetting to explicitly close the StreamWriter object guarantees
data loss. Microsoft expects that developers will see this consistent
loss of data and will fix the code by inserting an explicit call to
Close."
-- URL:http://msdn.microsoft.com/msdnmag/issues/1100/GCI/default.aspx


And don't look to IDisposable and finalizers to save you:


"Not absolutely guaranteed

"In addition to the issue that you don't know when the finalizer
will be called, you're not absolutely guaranteed that Finalize
will be called at all.

....

"The runtime continues to Finalize objects during shutdown only
while the number of finalizable objects continues to decrease."
-- http://msdn.microsoft.com/library/en-us/dnguinet/html/drguinet4_update.asp


Is this *really* where you want to go today?
 
Kevin said:
I discovered that, but unfortunately it doesn't work with this type
of routine:

For Each Control
If Control is Textbox Then
Control.ReadOnly = True
End If
Next

Or am I missing something?

dim c as control
For Each c In Me.Controls
If TypeOf c is Textbox Then
Directcast(c, Textbox).ReadOnly = True
End If
Next
 
Kevin said:
As long as I have the attention of all you VB.NET experts, let me ask
the question:

How can I make a textbox control so that the user can't edit the text,
without setting the Enabled property to False (I don't want the
contents greyed out)? I did this in VB6 by putting the textbox in a
frame and then disabling the frame. Can't do that in wonderful .NET...

You could have used the locked property in VB6. Thats what it was for.

in .NET, the similar property is ReadOnly I believe.
 
Whatever was wrong with setting the Locked property to True in VB
Classic? The user could still select and copy the text, though.
Anyway, VB.NOT is most definitely *not* better than VB, unless you
count *guaranteed data loss* as an 'advantage' as Micro$haft does:


"So, here is Microsoft's solution: the StreamWriter type doesn't
implement a Finalize method at all. Of course, this means that
forgetting to explicitly close the StreamWriter object guarantees
data loss. Microsoft expects that developers will see this consistent
loss of data and will fix the code by inserting an explicit call to
Close."
-- URL:http://msdn.microsoft.com/msdnmag/issues/1100/GCI/default.aspx

So, don't forget to close your streams...
And don't look to IDisposable and finalizers to save you:


"Not absolutely guaranteed

"In addition to the issue that you don't know when the finalizer
will be called, you're not absolutely guaranteed that Finalize
will be called at all.

...

"The runtime continues to Finalize objects during shutdown only
while the number of finalizable objects continues to decrease."
-- http://msdn.microsoft.com/library/en-us/dnguinet/html/drguinet4_update.asp


Is this *really* where you want to go today?

Joe, you left out the pertinet part there...

<quote>
Specifically, the Finalize method might not run to completion or might
not run at all in the following exceptional circumstances:

* Another finalizer blocks indefinitely (goes into an infinite
loop, tries to obtain a lock it can never obtain, and so on).
Because the runtime attempts to run finalizers to completion,
other finalizers might not be called if a finalizer blocks
indefinitely.

* The process terminates without giving the runtime a chance to
clean up. In this case, the runtime's first notification of
process termination is a DLL_PROCESS_DETACH notification.
</quote>

These are exceptional circumstances that are the result of programmer
error - not a problem with the runtime.
 
In VB6 all I did was put the controls in a Frame and then set the
Frame's Enabled property to False. The textboxes still looked normal
(not greyed out), but they couldn't receive focus. Worked quite well
with one line of code. Ahhh, the good ol' days.....
 
In VB6 all I did was put the controls in a Frame and then set the
Frame's Enabled property to False. The textboxes still looked normal
(not greyed out), but they couldn't receive focus. Worked quite well
with one line of code. Ahhh, the good ol' days.....

I don't know how you got the impression that every thing is easier in
..NET - because it's not. If you take it on a task-by-task basis, then
you will always find a task that easier in VB.CLASSIC then it is in
VB.NET - the question is which, overall, makes my life as a developer
easier and gets the job done? For you that may very well be VB.CLASSIC.
For others, that maybe VB.NET. For me it is C#, but that is another
story :)

It all boils down to what your trying to accomplish.
 
Hi Armin,

I did deliver that same routine to Kevin, but he did use it on his own way.
For Each c In Me.Controls
If TypeOf c is Textbox Then
Directcast(c, Textbox).ReadOnly = True
End If
Next

Or did you see that?

Cor
 
Hi Armin,

No the thread Kevin was refering at in his first message in this thread,
but it is not that much important, only that I saw that you did give exactly
the same answer as I did (you did use c and I ctr).

I do know that you did not overwrite it of course and nice was that it was
exactly the same.

Cor
 
Cor said:
No the thread Kevin was refering at in his first message in this
thread, but it is not that much important, only that I saw that you
did give exactly the same answer as I did (you did use c and I
ctr).

Ahh, ok, I found it now. Maybe I unintentionally started ignoring the
poster's names in this group (maybe because they are "sometimes" not real
names), that's why I didn't have the association.
I do know that you did not overwrite it of course and nice was that
it was exactly the same.

Yep, I didn't copy it. :-)
 
Hey!! I may be mad, but each of those items can apply to .NET too! :) Here
they are again without the egg references :)

1) It's bigger (god yes!)
2) It's fully OO instead of only a bit OO
3) Far easier to GPF in VB classic, especially when subclassing
4) The language can do SOO much more, which can be daunting for some VB
classic programmers, thus keeping them away
5) It's definately more expensive! :)

And now it's mad Monday :)

Lorne
 
* "Lorne Smith said:
Hey!! I may be mad, but each of those items can apply to .NET too! :) Here
they are again without the egg references :)

1) It's bigger (god yes!)

That's sometimes an advantage, but not when distributing an application
over the internet.
2) It's fully OO instead of only a bit OO

I wouldn't see that as a very big advantage.
3) Far easier to GPF in VB classic, especially when subclassing

This depends on the developer.
4) The language can do SOO much more, which can be daunting for some VB
classic programmers, thus keeping them away
Examples?

5) It's definately more expensive! :)

;-)
 
Hi,

I actually didn't want to post the following, but as the thread has been
picked up again I pulled it out of my template folder...


I have also worked with previous VB versions, but now I can ask the VB6
users:

- Where is inheritance? I want to add features and encapsulate my code where
it belongs to. Where is code reusage without (slow) delegation? How can I
inherit from interfaces?

- How can I structure big project without the availability of nested
namespaces? I didn't succeed while trying to keep expressive names. How can
I break the 39 chars ProgID length limit?

- Where is Option Strict? It helps me finding errors ASAP. The VB.NET
compiler found errors in upgraded DLLs that the VB6 compiler didn't find.

- Where are delegates? How can I store safe procedure pointers?

- How can I use the same event procedure for several controls *and* give
each control an expressive name?

- How can I overload methods? It's easier than using Add1, Add2, Add3, ...

- How can I overload declares? These "As Any" declarations can be dangerous.

- How can I use window subclassing without crashing the IDE when pressing
the stop button?

- How can I handle all the events that are not available in the nice combo
at the top of my code editor?

- How can I override WndProc?

- How can I enjoy free threading?

- How can I declare variables at block level? I can keep the names short
because of the narrow scope.

- Are there no OrElse or AndAlso keywords? Do I have to write nested
If..Then-s?

- How can I use keywords as names in code? I'd like to add a "Stop" method
to my class.

- How can I get rid of the default instance of all the Forms? Public
variables can be dangerous.

- Where are constructors? Some programmers, including myself, forgot to call
the Init sub after object creation. It shouldn't happen but it does.

- Why are my simple property-get procedures not optimized inline? Why are
even my public fields converted to property procedures? That's slowing down
things considerably.

- Why is there no garbage collection? COM reference counting can als slow
down things.

- Where is the type safety? It can be dangerous making the wrong Declare
statements. I'm usued to safely access C# assemblies from my VB.NET app.

- Why can I ReDim an array that hasn't been declared? That can be dangerous.

- How can I create an empty array? Redim x(0 to -1) does not work.

- How can I create nested classes?

- Why does the compiler not check whether the rank of two arrays match? I
could pass a one-dimensional array to a procedure taking a two-dimensional
array. => runtime error instead of compile error

- As there is no GC, how can I avoid the loss of memory occupying and
circulary referenced objects when removing a root reference?

- Where are the operators += -= and so on? Not a big deal but a little bit
less to type and a little bit safer.

- How can I freely create the structure of menus at runtime?

- It is not really intuitive to type "-4" in the procedure properties to get
an enumerable object.

- How can I create my own pens and brushes to avoid them being internally
created and destroyed more often than needed?

- How can I make Forms and other "instrinsic" objects public?

- How can an MDI container and it's children be contained in different
assemblies (without SetParent hacks that can also be dangerous)?

- Is there no Char or Long data type? Is the Decimal type only available as
Variant sub type?

- Is there no Return statement that can also return the function return
value?

- Why can't I use "Me.member" for private members to be able to use
intellisense?

- How can I pass a reference to an array to another object and have it store
the reference at class level?

- Why does the following expression return "False"? I expect the same object
is returned twice:
Printers(0) Is Printers(0)

- Why is the datatype name of a control array "Object"? Strange...
Debug.Print Typename(command1) 'command1 is a control array.

- Why do I get error 91 in the second line? Command1(index) *is* a
CommandButton.
Private Sub Command1_Click(Index As Integer)
Dim cmd As CommandButton
cmd = Command1(Index)
End Sub

- What strange syntax is this:
pic.line (0,0) - (100, 100), vbWhite, BF
Why not always separate arguments by a ","? What is BF? A string? A
constant or what?

- Why can't I write ".Line..." within a With block?

- Where are all the useful classes and new methods that are now available in
the Framework?

- Why does my IDE crash when my app crashes? Running in two processes is
much safer.


Comments:
- Items are in no specific order. Items are more or less important.
- These are only the items that I am personally interested in and that
spontaneously came into my mind.
- I do not say that all items are impossible in previous versions, but often
(a programmer's) life was really a lot harder.
- There are also several drawbacks now - but I don't dare to post them
*here*. :) Some of them would be IDE things anyway.
- It is not required to answer the questions above. - I also won't
discuss them (at) all. ;-))
 
Hi Armin,

Here is your solution :-)
- Why do I get error 91 in the second line? Command1(index) *is* a
CommandButton.
Private Sub Command1_Click(Index As Integer)
Dim cmd As CommandButton
cmd = Command1(Index)
End Sub
Because you did not enclose it in a try, catch end try block

:-)

Cor
 
Herfried,
I wouldn't see that as a very big advantage.
Its a significant advantage if you are an OO programmer!

However if you don't yet see the value of OO, then I agree its not an
advantage, and may actually be a hindrance ;-)

As you know I am a big proponent of OO programming!

Just a thought
Jay
 
Hi Jay B
As you know I am a big proponent of OO programming!

We know :-))

And you get all our support.

But it is not a religion, some of the goals has to be for me:
- good readable
- understandable
- reusable code

And till now I did not see a better way for that than OO.

But for a "say hello" program there is no need for it and I think that
Herfried has almost the same idea as I about this.

Cor
 
Cor said:
But for a "say hello" program there is no need for it and I think that
Herfried has almost the same idea as I about this.

To paraphrase a friend of mine (who said it about another language)...
"If you write Hello World programs for a living then .Net may not be the
best choice."
 
Tom,
I like that one, can I use it?

Thanks
Jay

Tom Leylan said:
To paraphrase a friend of mine (who said it about another language)...
"If you write Hello World programs for a living then .Net may not be the
best choice."
 
Hi Tom,

Ok then, I say it in another way, if a datatable is sufficient for me, I
would not make my own collection inheriting from Ilist.

Better so?

:-))

Cor

" > But for a "say hello" program there is no need for it and I think that
 
Hi Tom,

I have read a book from a guy in advertising, he describes very good what is
the difference between productivity and art.

He wrote something as that he likes it when the ones who makes art that was
useless for advertisment did work at his competitors.

Sometimes I get the feeling that there are programmers who are more busy
with art than with making productivity programs.

It is not from me.

Cor
 
Back
Top