时间: 2021-07-31 作者:daque
in vb6, you could call this sub in one of two ways:foo “hello ”call foo(“hello ”)in vb.net, you also could call this sub in one of two ways:foo(“hello ”)call foo(“hello ”)the difference, of course, is that the parentheses are always required in the vb.netcalls, even though you aren’t returning anything. the call statement is still sup-ported,but it is not really necessary.changes to boolean operatorsthe and , not , and or operators were to have undergone some changes. microsoftoriginally said that the operators would short-circuit, but now they are staying theway they worked in vb6. this means that in vb.net, as in vb6, if you had twoparts of an and statement and the first failed, vb6 still examined the second part.examine the following code:dim x as integerdim y as integerx =1y =0if x =2 and y =5/y then...as a human, you know that the variable x is equal to 1 . therefore, when you look atthe first part of the if statement, you know that x is not equal to 2 , so you would log-icallythink it should quit evaluating the expression. however, vb.net examines thesecond part of the expression, so this code would cause a divide-by-zero error.if you want short-circuiting, vb.net has introduced a couple of new operators:andalso and orelse . in this case, the following code would not generate an error invb.net:dim x as integerdim y as integerx =1y =0if x =2 andalso y =5/y then...this code does not cause an error; instead, because x is not equal to 2 , vb.net doesnot even examine the second condi