Convert VBS file to vb.net

R

Rick

I have a vbs file (WScript) that I need to convert to vb.net; is there any
tools available for that?
 
D

Dick Grier

None that I know of. I think you'd copy/paste/fix.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
Z

zacks

I have a vbs file (WScript) that I need to convert to vb.net; is there any
tools available for that?  

I'm not aware of any. VBS was based on VB6, so it would be very
similar to converting VB6 to VB.NET, only a VBS is a stand alone piece
of code that is normally interpeted, not compiled.
 
B

Bill McCarthy

But don't paste, instead use the "Upgrade Visual Basic 6 Code ... " item
from the Tools menu.
 
D

Dick Grier

For VBS? I doubt that would do much. Of course, VBS <> VB6 (I think).

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
B

Bill McCarthy

Dick Grier said:
For VBS? I doubt that would do much. Of course, VBS <> VB6 (I think).

Yeh should do, as VBS is a subset of VB6. The "Upgrade Visual Basic 6 Code
...." tool allows you to paste code into it, set references etc, and it will
do it's magic.
 
C

Cor Ligthert[MVP]

Bill McCarthy said:
Yeh should do, as VBS is a subset of VB6. The "Upgrade Visual Basic 6
Code ..." tool allows you to paste code into it, set references etc, and
it will do it's magic.
?????????????????????????????????????

What has VB6 to do with VBS, VBS did exist far before VB6.

As you had written VB6 contains a subset of VBS than it would have been a
little bit more in the direction.

However VB for Net has the same, so I would keep by Dick's first answer.
There was at least for me nothing to add to that, I would have written it
almost exactly the same.

Cor
 
B

Bill McCarthy

Cor Ligthert said:
?????????????????????????????????????

What has VB6 to do with VBS, VBS did exist far before VB6.

As you had written VB6 contains a subset of VBS than it would have been a
little bit more in the direction.

Absolutely not. VBScript is a derivative of VB. It was developed
originally for IE after VB4, then updated alongside VB5.
The upgrade wizard will fix much of the code, changing Integer to Short etc,
removing Set, Intialize to New, Terminate to Finally, and all those kind of
things.


However VB for Net has the same, so I would keep by Dick's first answer.


Huh ? Why manually convert somethign when the wizard will do it for you ?
 
C

Cor Ligthert[MVP]

Bill McCarthy said:
Absolutely not. VBScript is a derivative of VB. It was developed
originally for IE after VB4, then updated alongside VB5.
The upgrade wizard will fix much of the code, changing Integer to Short
etc, removing Set, Intialize to New, Terminate to Finally, and all those
kind of things.
Are you tired from a long trip or something?

You write "Absolute not" Or do you have the idea that VB6 was developed
before VB5.
Huh ? Why manually convert somethign when the wizard will do it for you ?
Because in this case there will not be anything different.

VBS does not use the same methods to use objects as VB6, by instance
DataBase access and Web access is completely different handled. (I have
done a lot in classic ASP, the keywords you are talking about I thought
never to have used in VBS, only declared once because everything is
global ).
The "Set" is automaticly removed by VB for Net by the way. You cannot even
use it.

To show it, try this and remove the double quotes around Set

Dim a As String
"Set" a = "1"

I wished that declaring variables (inside methods) i = 10 would be
optional possible in VB for Net.

However the strong advocacy from old VB6 users prefents that, because they
cannot think without that there is written Dim before it, even in a Global
situation, where this in my idea even should be avoided.

However, just my opinion.

Cor
 
B

Bill McCarthy

Cor Ligthert said:
Are you tired from a long trip or something?

You write "Absolute not" Or do you have the idea that VB6 was developed
before VB5.


Huh ? Vb5 is a subset of Vb6 right ? *Everything* you can do in VBScript,
you can do in VB6. VB6 has more features, hence VBScript is a subset.



Because in this case there will not be anything different.

Really. What about code like myColor = vbBlack ?
Or date operations Or the Sqr function etc.


VBS does not use the same methods to use objects as VB6, by instance
DataBase access and Web access is completely different handled. (I have
done a lot in classic ASP, the keywords you are talking about I thought
never to have used in VBS, only declared once because everything is
global ).


It's still the same objects, still the same COM libraries.
 
D

Dick Grier

OK. I've never used VBS, so I didn't realize that it was that compatible.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
B

Bill McCarthy

Yeh it's the same. Even has classes, property Lets and Gets and Sets.. yet
everything is a variant implicitly ;)
 
C

Cor Ligthert[MVP]

Bill,

There is a VB language and there is are a VB tool like VB 2008 .

VB Net 2008 by instance is based on VB version 9.

VBS is more or less compatible with all those versions, but not particular
to version 6.

Therefore I stay by the idea that your idea will only give a lot of extra
work for the OP, maybe he start enthousiast but after a time he will see
that what Dick wrote is a better option.

Cor
 
M

mayayana

It's not. That's a common misperception, especially
among C++ programmers who tend to lump anything
that looks basic-esque into one pile they call "VB".

There are even large differences in VBS where it's
used for ASP vs WSH vs webpage scripting. A simple
VBScript can often go directly into VB6 code, but anything
that's at all involved would probably need a rewrite.
And if it's going to be translated as reasonably good code
it would need a total rewrite, since VBScript is almost
always using slow, limited COM objects with dependencies,
like FileSystemObject and WScript.Shell.
I don't know anything about the VB -> VB.Net converter,
but I can't imagine that it's going to make much sense of
those objects, or of things like methods of the WScript
object, which only exists in the WSH context.
 

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

Similar Threads


Top