View the Web page source code today, inadvertently found that the source code trailer throws ASP error information, but not displayed on the Web page.
If you do not see the source code, you have not found the ASP running code error.
In the general case, in ASP, there is a variable to represent the user's current capacity, note that this variable is a string, format such as: 20.3M, 50.6G
The last character is either M or G
The program needs to make a judgment, if the user uses more than 50G of capacity, the pop-up message, the relevant code is as follows:
12345678910111213 |
<% str = "59.3G" if right(str,1) = "G" and cdbl(replace(str, "G" , "" )) > 50 then response.write( "> 50G" ) else response.write( "< 50G" ) end if %> |
Run output result: > 50G
When str = "600.3M", the program throws an error:
Microsoft VBScript Run-time error (0X800A000D)
Type mismatch: ' CDbl '
And did not output what I expected: < 50G
We use the same logic to rewrite it using Java:
12345678910 |
String str = "59.3G" ; if (str.endsWith( "G" ) && Double.parseDouble(str.replaceAll( "G" , "" )) > 50 ) { System.err.println( "> 50G" ); } else { System.err.println( "< 50G" ); } |
Results of the output:
> 50G
If String str = "630.3M";
Results of the output:
< 50G
Summarize:
From the above two kinds of code, in ASP, when judging multiple conditions (and), when the first condition is not established, will continue to determine whether the next condition is true:
Another validation code:
123456789101112131415161718192021 |
<% function abc() response.write( "abc()...<br>" ) abc = true end function str = "59.3M" int x if right(str,1) = "G" and abc then response.write( "> 50G" ) else response.write( "< 50G" ) end if %> |
Output:
ABC () ...
< 50G
In Java code, when a number of conditions (and, &) are judged, when the first condition is not set, the following criteria will not be judged, no longer execute the following judgment code.
2014-04-02
An error by ASP, see different languages: ASP & Java