True / False in classic VB
- Get link
- Other Apps
In classic VB (and classic ASP as well), zero is considered as false and any other non-zero integer is considered as true.
While debugging an asp page, I come across following line:
If Not Request.Form.Count Then
...
Now form count was 2 (true) so the condition should evaluate as false (Not true). But this was always evaluating as true. It took me half an hour to find the catch.
What actually happening here was that Not is a bit-wise operator in VB. It flips the bits. So,
2 is 0000 0010 in binary.
NOT 2 is 1111 1101 in binary.
Considering that the last bit is sign bit, this becomes -3.
Now our condition If NOT (2) becomes If (-3), which always evaluates to true (non-zero integers are always true in VB).
- Get link
- Other Apps
Popular posts from this blog
Redirecting to new window in c#
As a developer, many time I wished to redirect user to a new URL into a new browser window. I wanted to use response.redirect at server side and open the new web page into a new window. But the way redirection works makes it impossible to open a new window from server side. The common solution to this problem is to use java script's window.open statement at client side and then fetch the new URL into the new window. To me, this is totally unacceptable while I am writing server side code. So I decided to write some code to do this. But before writing, I googled for the same. I found a good solution for the problem. I would like to give proper credit to the author, who chose not to publish his/her name. As they say a code worth one thousand words, here is the code: ResponseHelper Class: The ResponseHelper class does all the magic. It adds a client side script to the response which opens the new window. Use this class in place of response class if you want to open new window. Yo
CBSE Class X Result 2010 – How to Calculate Percentage
Today, CBSE Board, India declared class X result for year 2010. But here is a catch – this year they changed the rating from numbers to grades. Most of the students are apparently confused how to get percentage from their GPA. How to convert CGPA to Percentage Here is the simple method to convert GPA into percentage: Percentage = 9.5 × CGPA Example: CGPA = 6.8 Percentage = 9.5 x CGPA = 9.5 x 6.8 = 64.60% The percentage calculated by this manner is the overall percentage. How to convert GP to Percentage Here is the simple method to calculate percentage from GP: Percentage = 9.5 x GP Example: GP = 06 Percentage = 9.5 x 6 = 57.6%. The percentage calculated in this manner is the percentage in that particular subject. Technorati Tags: CBSE , CBSE Result , CBSE Result 2010 , Percentage from GPA SUBJECT WISE GRADE POINT: Marks Range Grade Grade Point