When you write the ASP code that can save time, if you want to transplant the code, there are many things to do. Follow the steps below, you will
It is not troublesome to find the transplant code.
Determine variable type
The biggest disadvantage of Visual Basic and VBScript is that it allows developers to use variables without declaration. If you think this is a benefit,
Then when you want to find a logical error caused by a small typing error, you don't think about it. If you use
If Option Explicit is forced to clarify, the IDE will warn this.
< %@ Language = VBScript %>
< % Option Explicit %>
When you use Option Explicit, remember that it happens to be under@ Declarations. Not paying attention to this will lead to a small one
error message.
Microsoft VBScript Compilation error '800A0400'
exfection statement
/test.asp, LINE 4
option explicit
^
Now the challenge is here. VBScript allows the variable to be any data type, as long as it is Variant. This means you can only put the variable
The statement is Variants. This is very wasteful in many aspects, but it is acceptable in ASP. But in Visual Basic
When creating more effective code, the variables must be defined. This program is very simple, just add AS after the statement
[data_type], at this time it is no longer a simple variant.
For example, there is now a variable as a string. Open an ASP page and type Dim StrSense as String. Then
Preview this page will get a small surprise.
Microsoft VBScript Compilation error '800A0401'
exfection end of statement
/icu/temp.asp, line 3
DIM StrSession as String
----------------------
So, how to make a variable that does not threaten the ASP code and prepare for Visual Basic? I can't be sure how to evaluate this. have
One way is to use annotation tags after variable declaration. It should be noted that this is not only helpful when transplanted to VB, it is different
When the company provides high salaries to dig you, this will help others understand your code. The following is a comment label in ASP version 2
Determine the three ways of variables:
Private StRSTRING 'AS String
DIM Intinteger 'AS Integer
Public Bolboolean 'as Boolean
This data type definition technique also applies to any function you use in ASP applications. (Please look at the following subroutines and functions below).
Private Function (StRTRING, Intinteger) 'as Boolean
When I knocked into my ASP code, I also penetrated these comments. This may not be suitable for you, maybe you are dealing with some old code,
After transplanting code, you can use the search and replacement function of Visual Basic to increase the data type. This is more meaningful because
Do not comment variables in functions and subroutines. The more programmatic code, the less the variable data type comments.
For more information about the Visual Basic data type, you can refer to the online article of MSDN related data types.