INFO: Converting VBScript to VB.NET::Variable Allocation and Typing 
Author Message
 INFO: Converting VBScript to VB.NET::Variable Allocation and Typing

Porting VBScript to VB.NET for special purposes is possible.  I've been looking
at some of the details of how code ports, and have some notes on this that may
be of interest.

One of the cornerstones of scripting is the ability to enforce explicit variable
allocation (via Option Explicit), but allow dynamic typing of variables.

It turns out that this works fine in VB.NET, using the default option settings.
There are two option declarations in VB.NET, covering making variable allocation
explicit (Option Explicit On) and making variable typing strict (Option Strict
On).

For classic VBScript requiring pre-allocation, the initial option settings
should be

Option Explicit On
Option Strict Off

With Strict "Off" you are not required to set a type; thus statements like the
following

    dim a, b(), c
    a = 9
    a = "this is a string"
    ReDim b(4)

work ok.

There are some issues with the methods we normally use to check and explicitly
cast types, but type coercion behaves almost identically.

--
Please respond in the newsgroup so everyone may benefit.
  http://www.*-*-*.com/
(email requests for support contract information welcomed)
 ----------
 Subscribe to Microsoft's Security Bulletins:
  http://www.*-*-*.com/



Fri, 29 Jul 2005 04:49:52 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Convert HTML Input Box info to a variable VB script can use

2. Convert VB.Net to C#, convert C# to VB.Net

3. VB.NET: Steps for Converting a Windows .NET Application to a Web .NET Application

4. Q: Converting VB types to equivalent C types

5. problem of converting C's union type to VB's a data type

6. problem of converting C's union type to VB's a data type

7. Q: Converting VB types to equivalent C types

8. convert app written in VB to the net

9. Converting variables from one type to another

10. How to convert object type variable to string

11. Converting a VB.Net source to a C#.Net source

12. Dynamic mem allocation via array names as variables

 

 
Powered by phpBB® Forum Software