getting rid of old vb6 code

C

chookeater

Hi All.

My introduction to VB was through VB.Net but I am working with a lot
of code that was written by programmers with pre-dotnet experience. As
a result there are lots of function calls and "non-OOP aware" code.

Is there any program available that I can get to sweep through VB.Net
projects and flag these older VB functions/things ?

I don't want to have to learn pre-dotnet VB to just to know what I
should be getting rid of.

Thanks in advance (perhaps)
Chook.
 
S

Scott M.

You could remove the reference to the Microsoft.VisualBasic namespace and
see what breaks.
 
C

Cor

Hi Scott,

What has the Microsoft.VisaualBasic namespace to do with non OOP
programming?

Cor
 
H

Herfried K. Wagner [MVP]

* (e-mail address removed) (chookeater) scripsit:
My introduction to VB was through VB.Net but I am working with a lot
of code that was written by programmers with pre-dotnet experience. As
a result there are lots of function calls and "non-OOP aware" code.

Is there any program available that I can get to sweep through VB.Net
projects and flag these older VB functions/things ?

I don't want to have to learn pre-dotnet VB to just to know what I
should be getting rid of.

Maybe this tool will help you:

Micrososoft Visual Basic Code Advisor
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvb600/html/vb6_FixItRuleTool.asp>
 
S

Scott M.

Cor said:
Hi Scott,

What has the Microsoft.VisaualBasic namespace to do with non OOP
programming?

Cor

I know this is bound to open a can of worms here, but much of what is in
that namespace is throwbacks to the "old" VB 6.0 syntax. MsgBox() for
example.

The OP said he was looking for a way to get away from VB 6.0 functions and
get more to OOP techniques. If I take away the MsgBox() function, you are
left with the MessageBox class and its show method, which is the more OO
approach.
 
C

Cor

Hi Scott,

Something that is C style code is not OOP, C style keywords have nothing to
do with OOP

OOp is today the best way to get reusable uniform code

To archive that you can use things as overloading, inheriting, protecting,
etc.

But maybe am I wrong and is using

dim a as string = b.substring(0,2) instead of a MID function complete OOP.
But from that I see no benefit in reusable uniform code.

(I myself use mostly the C style code, but that is mainly because of the
zero indexer)

But please correct me if I am wrong?

Cor
 
S

Scott M.

I really don't know what "C style code" is supposed to mean, so I really
can't follow what you are trying to say in your post.
 
H

Herfried K. Wagner [MVP]

* "Scott M. said:
I know this is bound to open a can of worms here, but much of what is in
that namespace is throwbacks to the "old" VB 6.0 syntax. MsgBox() for
example.

I still don't know what's bad about 'MsgBox' and the other functions.
The OP said he was looking for a way to get away from VB 6.0 functions and
get more to OOP techniques.

I think he wanted to get back from a bad application design using
various modules. Using 'MsgBox' isn't bad. Using the
non-object-oriented '+' operator isn't bad too.
If I take away the MsgBox() function, you are
left with the MessageBox class and its show method, which is the more OO
approach.

IMO there isn't any difference. The 'Show' method of the 'MessageBox'
is a static method too.
 
H

Herfried K. Wagner [MVP]

* "Cor said:
Something that is C style code is not OOP, C style keywords have nothing to
do with OOP

ACK. C was an OOP-less programming language...
OOp is today the best way to get reusable uniform code

To archive that you can use things as overloading, inheriting, protecting,
etc.

But maybe am I wrong and is using

dim a as string = b.substring(0,2) instead of a MID function complete OOP.
But from that I see no benefit in reusable uniform code.

That's the main point. It doesn't matter if you use 'MsgBox' or
'MessageBox.Show' as it doesn't matter if you use 'Substring' or 'Mid'.
What matters, is the design, the architecture of the application. A
good class design which is CLS compliant.
 
H

Herfried K. Wagner [MVP]

* "Scott M. said:
I really don't know what "C style code" is supposed to mean, so I really
can't follow what you are trying to say in your post.

My interpretation: Procedural programming.
 
S

Scott M.

And what does this have to do with our prior posts about the
Microsoft.VisualBasic namespace?
 
S

Scott M.

Herfried K. Wagner said:
I still don't know what's bad about 'MsgBox' and the other functions.

This is the "can of worms" I mentioned earlier because there are strong
opinions on both sides of the fence. When you use the MsgBox() function,
all that happens is that a call to the .show method of the MessagBox class
occurs. Why take the extra step with the function when you can go straight
to the functionality you want with the method.
I think he wanted to get back from a bad application design using
various modules. Using 'MsgBox' isn't bad. Using the
non-object-oriented '+' operator isn't bad too.

See above.
IMO there isn't any difference. The 'Show' method of the 'MessageBox'
is a static method too.

But there is an extra processing step when using the MsgBox() function.
 
C

Cor

Hi Scott,

With Removing the Microsoft.Visual.Basic namespace you are not making OOP
programs,

You are restricting yourself useless by only using a part of the .Net
framework.

Cor
 
A

Armin Zingler

Scott M. said:
This is the "can of worms" I mentioned earlier because there are
strong opinions on both sides of the fence. When you use the
MsgBox() function, all that happens is that a call to the .show
method of the MessagBox class occurs. Why take the extra step with
the function when you can go straight to the functionality you want
with the method.


- I'm used to msgbox
- Messagebox.Show is more to type
- The overhead with Msgbox is unimportant (UI stuff; user won't notice it)

My 2 Euro-c.
 
H

Herfried K. Wagner [MVP]

* "Scott M. said:
This is the "can of worms" I mentioned earlier because there are strong
opinions on both sides of the fence. When you use the MsgBox() function,
all that happens is that a call to the .show method of the MessagBox class
occurs. Why take the extra step with the function when you can go straight
to the functionality you want with the method.

Reducing the "complexity" of the code for common tasks.
But there is an extra processing step when using the MsgBox() function.

Who cares? That's some ns of processing.
 
H

Herfried K. Wagner [MVP]

* "Scott M. said:
And what does this have to do with our prior posts about the
Microsoft.VisualBasic namespace?

You can use the methods without adding the name of the module they
reside in. Maybe that's what Cor means.
 
H

Herfried K. Wagner [MVP]

* "Cor said:
With Removing the Microsoft.Visual.Basic namespace you are not making OOP
programs,

ACK, you can still use modules, for example.
You are restricting yourself useless by only using a part of the .Net
framework.

:)
 
S

Scott M.

Cor said:
Hi Scott,

With Removing the Microsoft.Visual.Basic namespace you are not making OOP
programs,

You are restricting yourself useless by only using a part of the .Net
framework.

Which is EXACTLY what the OP said he wanted to do: "Is there any program
available that I can get to sweep through VB.Net projects and flag these
older VB functions/things ?"

By disabling the Microsoft.VisualBasic namespace, you disable many of the
old VB 6 functions and therefore you are left with the new .NET object
methods (which, as I stated earlier are usually more efficient because there
is no extra step to invoke them).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top