解决方案 " Dune" <一个******* @ discussions.microsoft.com>在消息中写道 news:04 **************************** @ phx.gbl ... 如何将布尔值与Nothing进行比较? 我不能说如果boolVar没什么因为布尔值不是引用类型,而是如果boolVar = Nothing,总是似乎返回true,即使布尔值为 true或false。 干杯 我可能错了,但我不认为布尔值永远都不算什么......我认为 它被初始化为FALSE,但是你可以很容易地检查它,做一个表格 或app,制作一个布尔值,然后单步执行代码,观察当地人 窗口,看看那个吸盘是什么样的。我的解决方案,在 初始化程序中,例如Sub Main,或FormLoad,我明确地设置了那个吸盘并以这种方式交易 ,我不喜欢不确定。 HTH Sueffel --- 外发邮件已通过无病毒验证。 由AVG反病毒系统检查( http://www.grisoft.com)。 版本:6.0.558 /病毒数据库:350 - 发布日期:1/2/2004 " Dune" <一个******* @ discussions.microsoft.com> schrieb 如何将布尔值与Nothing进行比较? 完全没有。 我不能说如果boolVar没什么因为布尔值不是引用类型, 对 但是如果boolVar = Nothing总是似乎返回true,即使布尔值为 true或false。 No: false = nothing => true true = nothing => false 不要对值类型使用Nothing。这没有意义。不幸的是, 是可能的。值类型的任何值都不等于值类型的默认值 ,布尔类型的值为False。 - Armin http://www.plig.net /nnq/nquote.html http:// www.netmeister.org/news/learn2quote.html 嗯,是的,你是对的。一个布尔值总是初始化 为假。 这对我来说有点问题...我想检查 什么都没有,所以我可以控制存储的 程序的参数...所以如果boolVar是Nothing,我将传递 DBNull.Value作为参数和boolVar是不是 没什么,我会传递boolVar的值。哦,好吧, 猜我必须找到一个不同的方法。 感谢快速回复:) -----原始信息----- 沙丘 <一个******* @ discussions.microsoft.com>写在 messagenews:04 **************************** @ phx.gbl ... 我如何将布尔值与Nothing进行比较? 我不能说如果boolVar没什么因为布尔值不是引用类型,而是如果boolVar = Nothing,总是似乎返回true,即使布尔值的值为真/假。 干杯我可能错了,但我不是认为一个布尔可以 没什么..我认为它被初始化为FALSE,但你可以很容易地检查那个,制作一个formor应用程序,做一个布尔值,并逐步完成代码,观看localswindow,看看那个吸盘是什么样的。我的解决方案,在初始化程序中,例如Sub Main,或FormLoad,我明确设置那个吸盘并以这种方式处理它,我不喜欢不确定。 HTH Sueffel --- 发送邮件经过无病毒认证。由AVG反病毒系统检查( http://www.grisoft.com)。版本:6.0.558 /病毒库:350 - 发布日期: 1/2/2004 。 How do I compare a boolean with Nothing? I can''t say "If boolVar Is Nothing" because a boolean isnot a reference type, but "If boolVar = Nothing" alwaysseems to return true, even if the boolean has a value oftrue or false. Cheers 解决方案 "Dune" <an*******@discussions.microsoft.com> wrote in messagenews:04****************************@phx.gbl... How do I compare a boolean with Nothing? I can''t say "If boolVar Is Nothing" because a boolean is not a reference type, but "If boolVar = Nothing" always seems to return true, even if the boolean has a value of true or false. Cheers I may be wrong, but I don''t think a Boolean can ever be nothing.. I thinkit''s initialized as FALSE, but you can very easily check that, make a formor app, make a boolean, and step through the code, watching the localswindow and see what that sucker get''s inited as. My solution, in theinitializer, eg Sub Main, or FormLoad, I explicitly set that sucker and dealwith it that way, I don''t like being unsure.HTHSueffel---Outgoing mail is certified Virus Free.Checked by AVG anti-virus system (http://www.grisoft.com).Version: 6.0.558 / Virus Database: 350 - Release Date: 1/2/2004"Dune" <an*******@discussions.microsoft.com> schrieb How do I compare a boolean with Nothing?Not at all. I can''t say "If boolVar Is Nothing" because a boolean is not a reference type,right but "If boolVar = Nothing" always seems to return true, even if the boolean has a value of true or false. No:false = nothing => truetrue = nothing => falseDon''t use Nothing with value types. It doesn''t make sense. Unfortunatelly itis possible. Nothing used with value types is equal to the default value ofthe value type, this is False for the Boolean type.--Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html hmmm, yes, you''re right. A boolean is always initialisedto false. this is kinda a problem for me...i wanted to check forNothing so i can control the parameters for a storedprocedure...so if boolVar is Nothing, i will pass inDBNull.Value as the parameter and if boolVar is NOTNothing, i will pass in the value of boolVar. Oh well,guess i''ll have to find a different approach. thanks for the quick reply :) -----Original Message-----"Dune" <an*******@discussions.microsoft.com> wrote inmessagenews:04****************************@phx.gbl... How do I compare a boolean with Nothing? I can''t say "If boolVar Is Nothing" because a boolean is not a reference type, but "If boolVar = Nothing" always seems to return true, even if the boolean has a value of true or false. CheersI may be wrong, but I don''t think a Boolean can ever benothing.. I thinkit''s initialized as FALSE, but you can very easily checkthat, make a formor app, make a boolean, and step through the code,watching the localswindow and see what that sucker get''s inited as. Mysolution, in theinitializer, eg Sub Main, or FormLoad, I explicitly setthat sucker and dealwith it that way, I don''t like being unsure.HTHSueffel---Outgoing mail is certified Virus Free.Checked by AVG anti-virus system (http://www.grisoft.com).Version: 6.0.558 / Virus Database: 350 - Release Date:1/2/2004. 这篇关于布尔和没什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-22 22:46