[Gambas-user] strange problem with NOT

machaira at ...734... machaira at ...734...
Fri Mar 18 20:43:40 CET 2005


I don't use VB6 anymore, but here's the output in VB.NET:

X is 1
NOT x = 0 returned true
NOT (x = 0) returned true
X is 0
x = 0 returned TRUE

Jim Perry
-------------- Original message -------------- 

> Hi, 
> 
> I found this "problem" with NOT , I'm pretty sure VB doesn't behave this 
> way 
> 
> for this code 
> 
> DIM X as Integer 
> 
> x = 1 
> PRINT "X is 1" 
> IF x = 0 THEN PRINT "x = 0 returned TRUE" 
> IF NOT x = 0 THEN PRINT "NOT x = 0 returned true" 
> IF NOT (x = 0) THEN PRINT "NOT (x = 0) returned true" 
> 
> x = 0 
> PRINT "X is 0" 
> IF x = 0 THEN PRINT "x = 0 returned TRUE" 
> IF NOT x = 0 THEN PRINT "NOT x = 0 returned true" 
> IF NOT (x = 0) THEN PRINT "NOT (x = 0) returned true" 
> 
> if you run this you'll get the surprising output 
> 
> X is 1 
> NOT (x = 0) returned true 
> X is 0 
> x = 0 returned true 
> 
> 
> it's as if NOT was a function NOT() and not a logic keyword ! 
> 
> I'm pretty sure vb would have turned both 
> 
> NOT x = 0 returned true 
> NOT (x = 0) returned true 
> 
> (that is if VB had a PRINT function ;) ) 
> I don't have vb installed right now so I can't test , but that 
> behavior sure puzzled me in the form of a bug in my program !!! 
> 
> --- 
> Jean-Francois Perreault 
> 
> 
> ------------------------------------------------------- 
> SF email is sponsored by - The IT Product Guide 
> Read honest & candid reviews on hundreds of IT Products from real users. 
> Discover which products truly live up to the hype. Start reading now. 
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click 
> _______________________________________________ 
> Gambas-user mailing list 
> Gambas-user at lists.sourceforge.net 
> https://lists.sourceforge.net/lists/listinfo/gambas-user 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20050318/d8f4231c/attachment.html>


More information about the User mailing list