using classes vs. modules

  • Thread starter Thread starter Andy B.
  • Start date Start date
Andy B. said:
"I don't have 2008 here but this doesn't work on 2005. In 2008 don't you
have to type T and then down arrow followed by space?"

No. If you go to Options>project defaults>visual basic and turn the "code
prettier" on then all you have to do is:

if(x = 0) [hit enter here and the then...end if is automatically added]


Also if you are in that same dialog (visual basic project defaults) and
you turn on the automatically fix errors, then vs will reformat your code.

'I can type this in the code window
dim PersonsAge Integer

'And after hitting enter it will rewrite the line as...
dim PersonsAge as Integer

Basically if you have these 2 features in vs2008 turned on it minimizes
your typing and coding. You can go back and customize the autogenerated
code, but I would imagine for some code writers it would be a pain in the
neck having to rewrite autogenerated code. For me it works wonders because
when i use new features in vb like inherits or implements it helps out
when I don't know what I'm doing.

I didn't realise you could do that. I think there is a similar feature in C#
that will do the squigglies for you but I haven't looked into it yet. I
think I hit the right key combination once to get it to work but I could
only do it once.

Michael
 
As I am active in this end the C# newsgroup, I am curious
why do we see you [Michael C] so terrible active here and
less in the C# newsgroup.

Because he's a troll. He goes where he can do the most damage and have the
most fun doing it.
 
Branco said:
Amen. Completely aggreed, thank you very much.

It should be quite obvious that most folks hanging out here and
helping out people (even the lurkers and the ones requesting help)
aren't interested in changing languages.

Unfortunately that won't stop the trolls. Speaking of which, I hereby
motion to elect Michael C. the troll of the month.

You can call me a troll if you like just because I don't say what you want
to hear.

Michael
 
Hello Michael,
Seconded...

You can call me a troll if you like just because I don't say what you
want to hear.

I doubt you'll get any takers here Michael.

You've little positive comment (actually none that I can find).

The clue is in the title "...languages.vb".

Surprised you hadn't figured that out already
 
That is not true. C# has a larger number of compiler checks than VB
and will catch quite a few more errors. In C# you need to do a
compile (ctrl-shift-b) and it will give you a list of errors. Many of
these errors are just plain missed in VB.

You really are speaking of errors? You mean that in VB there are hidden
errors? If there were _errors_, an application would not run, whether
they were shown up or not.

If there are more real error warnings in C#: Maybe, C# allows you to
make more different kinds of errors, for that more errors have to be
shown up by the compiler.

One example: In C# you have to initialize a variable with some value.
If you forget the initialization the compiler would warn you. In VB
there is no need for such an initalization, because a variable is
automatically initialized to a type's default value. Therefore the
compiler needs not to show up an error.

Or, did you mean some style cop violations, which, in VB, have no
meaning and weren't shown? Again, maybe that's because in C# it is
easier to violate some style guides.


Harald M. Genauck

"VISUAL STUDIO one" - http://www.visualstudio1.de
"ABOUT Visual Basic" - http://www.aboutvb.de
 
You really are speaking of errors? You mean that in VB there are hidden
errors? If there were _errors_, an application would not run, whether
they were shown up or not.

If there are more real error warnings in C#: Maybe, C# allows you to
make more different kinds of errors, for that more errors have to be
shown up by the compiler.

One example: In C# you have to initialize a variable with some value.

Only local variables. And this isn't true 100% of the time, just 99% of the
time :) If the value is to be passed as an out parameter, then the
initialization is not required because it is guarenteed to be initialized by
the called function...

This a personal thing, but in all the years I programmed VB, the two things
that bugged me most was case insensitivity and the default initialization bit.
I have always felt that forcing explicit initialization was the better, and in
the long run safer approach.

And just for everyones benifit - C# as of VS2008 does background compile by
default.
 
And just for everyones benifit - C# as of VS2008 does background compile
by
default.
And that despite that we have heard at least 5 years that it is not clever
to do.
Read Jon Skeets pages for that.

:-)

Cor
 
Hello Michael,
I don't have 2008 here but this doesn't work on 2005. In 2008 don't you have
to type T and then down arrow followed by space?

If x < 0 [RETURN]

will result in:

If x < 0 Then

End If


in VB.NET 2008. In 2005 I'm not sure as I haven't touched it for quite a
while. But I think that 2005 had that feature already.

Best regards,

Martin
 
Hello Harald,
One example: In C# you have to initialize a variable with some value. If
you forget the initialization the compiler would warn you. In VB there
is no need for such an initalization, because a variable is
automatically initialized to a type's default value. Therefore the
compiler needs not to show up an error.

Can that be set up anywhere? Because for strings, it always defaults to
Nothing whereas VB6 defaulted to an empty string. (I use VB.NET 2008
Express Edition.)

Best regards,

Martin
 
Tom Shelton said:
Only local variables. And this isn't true 100% of the time, just 99% of
the
time :) If the value is to be passed as an out parameter, then the
initialization is not required because it is guarenteed to be initialized
by
the called function...

This a personal thing, but in all the years I programmed VB, the two
things
that bugged me most was case insensitivity and the default initialization
bit.
I have always felt that forcing explicit initialization was the better,
and in
the long run safer approach.

And just for everyones benifit - C# as of VS2008 does background compile
by
default.

It does? I've installed 2008 on a couple of machines and it's never done it
by default.

Michael
 
Harald M. Genauck said:
You really are speaking of errors? You mean that in VB there are hidden
errors? If there were _errors_, an application would not run, whether they
were shown up or not.

If there are more real error warnings in C#: Maybe, C# allows you to make
more different kinds of errors, for that more errors have to be shown up
by the compiler.

One example: In C# you have to initialize a variable with some value. If
you forget the initialization the compiler would warn you. In VB there is
no need for such an initalization, because a variable is automatically
initialized to a type's default value. Therefore the compiler needs not
to show up an error.

Or, did you mean some style cop violations, which, in VB, have no meaning
and weren't shown? Again, maybe that's because in C# it is easier to
violate some style guides.

You're barking up the wrong tree. C# warns about real errors that VB will
miss and only become a problem at run time. As an example, have a look at
this code:

Function ABC As Integer
Dim y as Integer
y = 5
End Function

There are 2 errors in this function that VB will miss. The more minor one is
that y is only ever set and never used. The more serious one is that it
doesn't warn that you have forgotten to return a value. This could become
quite a serious problem especially in a more complex function when you
forget to return a value from just one of the branches. I'm sure there's
plenty more that VB doesn't warn you about.

Michael
 
Martin H. said:
Hello Harald,


Can that be set up anywhere? Because for strings, it always defaults to
Nothing whereas VB6 defaulted to an empty string. (I use VB.NET 2008
Express Edition.)

Actually VB6 defaulted to nothing (or was it empty) but not empty string.
 
You're barking up the wrong tree. C# warns about real errors that VB
will miss and only become a problem at run time. As an example, have a
look at this code:

Function ABC As Integer
Dim y as Integer
y = 5
End Function
There are 2 errors in this function that VB will miss. The more minor
one is that y is only ever set and never used.

I can't speak for VB2005 as I cannot remember if this was a problem then,
however it is not in VB2008 which has been out for over a year now
The more serious one is
that it doesn't warn that you have forgotten to return a value. This
could become quite a serious problem especially in a more complex
function when you forget to return a value from just one of the
branches.

The upcoming VB10 will be the 3rd straight release for which your statement
is simply not true.
Do your research... Your information is flawed again.
I'm sure there's plenty more that VB doesn't warn you about.

I'm sure you are very sure. I'm also sure nobody here cares.
Nobody here is in need of conversion.
Try door to door I hear thats the way religious zealots do things these days.

Failing that ... Go find a bridge.
 
Michael,

Funny that this is mentioned.

You see often confusion by solely C# users about the string.

The string is an object which can have no reference (impossible in C#)

In that situation the object is nothing (sentence does not work in C#, not a
dialect, simple a language distinct)

The string can has well be empty (you can see that if you use indexof by
instance which gives back -1 when it is like that) then the reference =
nothing.

As you use if stringA = nothing, then a non referenced string will be first
set to its default value and then the test will be evealuated and therefore
is true.
Very handy because that is then the exact value you want in a string. This
is impossible to do in C#/

Cpr
 
Rory Becker said:
I can't speak for VB2005 as I cannot remember if this was a problem then,
however it is not in VB2008 which has been out for over a year now


The upcoming VB10 will be the 3rd straight release for which your
statement is simply not true.
Do your research... Your information is flawed again.

Did you actually try this? I tried that exact code before posting and the
errors returned were zero, zip, nil, nada, nothing. I tried it in 2005 also
and again got no errors. Are you sure it isn't your information that is
flawed? :-)
I'm sure you are very sure. I'm also sure nobody here cares. Nobody here
is in need of conversion.
Try door to door I hear thats the way religious zealots do things these
days.

Failing that ... Go find a bridge.

Um, ok Rory.

Michael
 
Rory Becker said:
I doubt you'll get any takers here Michael.
You've little positive comment (actually none that I can find).

The clue is in the title "...languages.vb".

Surprised you hadn't figured that out already

It appears you've given up on using logic

Michael
 
It does? I've installed 2008 on a couple of machines and it's never done it
by default.

It is at least in sp1. Options->Tools-Text Editor->C#->Advanced, under the
Editor Help section -> Show live semantic errors.
 
Michael,

Funny that this is mentioned.

You see often confusion by solely C# users about the string.

LOL... That's a laugh. Most of the people I see thinking a string is a value
type are VB users.
The string is an object which can have no reference (impossible in C#)

Your confused here I think... C# forces initialization of local variables,
but it is still possible to have null reference - you just have to set it
explicitly:

string s = null;

On a field level, a string variable will default to null.
In that situation the object is nothing (sentence does not work in C#, not a
dialect, simple a language distinct)

The string can has well be empty (you can see that if you use indexof by
instance which gives back -1 when it is like that) then the reference =
nothing.

if you call indexof on a null string you get a NullReferenceException.
As you use if stringA = nothing, then a non referenced string will be first
set to its default value and then the test will be evealuated and therefore
is true.
Very handy because that is then the exact value you want in a string. This
is impossible to do in C#/

I'm not sure I'm understanding you at all... stringA == null is perefectly
valid in C#..
 
I can't speak for VB2005 as I cannot remember if this was a problem then,
however it is not in VB2008 which has been out for over a year now


The upcoming VB10 will be the 3rd straight release for which your statement
is simply not true.
Do your research... Your information is flawed again.


I'm sure you are very sure. I'm also sure nobody here cares.
Nobody here is in need of conversion.
Try door to door I hear thats the way religious zealots do things these days.

Failing that ... Go find a bridge.

Actually, Rory - I just tried it in 2008 and he's right on both accounts. I
can explain to you why the return thing happens - it's a side effect of:

1) using the function name as a return value
2) defualt initialization of variables

See, it's possilbe in VB to return a value from a VB function by assigning to
it's name:

Function Func() As Integer
Func = 5
End Function

That's perfectly valid. The return statement is optional in VB.NET. Also,
because VB auto initializes local values (a very evil practice - and one I've
always hated in VB), then Func will always return 0.
 
Back
Top