如何判断一个数值型变量是否为

michaelmodna 2009-01-19 04:59:03
如CFM_AMT 为数值型 ,条件需要判断是否为空:

Private Shared Function ModifyPersonDNA(ByVal CFM_AMT As integer) As bollean
if CFM_AMT is null then
....
end if

end function

请问应该如何实现这种判断呢,谢谢!
...全文
128 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
晓轩 2009-01-21
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 Jessie_Zhang 的回复:]
学习一下
不解:Integer类型的变量怎么会为空呢,如果不初始化默认的也应该是0啊
[/Quote]
顶。不知道LZ为啥要这样判断,有意义吗/
Jessie_Zhang 2009-01-21
  • 打赏
  • 举报
回复
学习一下
不解:Integer类型的变量怎么会为空呢,如果不初始化默认的也应该是0啊
LSSQXT 2009-01-20
  • 打赏
  • 举报
回复
vs2005开始都是.net 2.0了吧
a2krh 2009-01-20
  • 打赏
  • 举报
回复
If CFM_AMT Is Nothing Then
michaelmodna 2009-01-20
  • 打赏
  • 举报
回复
我用的是.net 2002的版本,应该如何定义呢,谢谢
vrhero 2009-01-19
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 michaelmodna 的回复:]
to “feiyun0112 ”:

CFM_AMT.HasValue 这个好象不行阿,HasValue是哪个对象才会出现呢?
[/Quote]
.NET 2.0以上版本才支持...
vrhero 2009-01-19
  • 打赏
  • 举报
回复
值类型不可为null...你可以用可空类型,2.0以上支持...

改成...
ByVal CFM_AMT As Nullable(Of Integer)
michaelmodna 2009-01-19
  • 打赏
  • 举报
回复
to “feiyun0112 ”:

CFM_AMT.HasValue 这个好象不行阿,HasValue是哪个对象才会出现呢?
michaelmodna 2009-01-19
  • 打赏
  • 举报
回复
to “jcobra”:

我用 If CFM_AMT Is DBNull.Value Then 时出错了,显示

“CFM_AMT ”is requires opernads that have reference types,but this operand has the value type decimal

请问是何解呢??

feiyun0112 2009-01-19
  • 打赏
  • 举报
回复
Private Shared Function ModifyPersonDNA(ByVal CFM_AMT As Nullable(Of Integer)) As Boolean
if not CFM_AMT.HasValue then

End Function

ModifyPersonDNA(nothing)

*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码)

http://feiyun0112.cnblogs.com/
jcobra 2009-01-19
  • 打赏
  • 举报
回复
因为有 ByVal CFM_AMT As integer 这一定义,所以 CFM_AMT 的值不会为空值的,默认为0

如果是string类型 ,则可以如下方法:
If CFM_AMT Is DBNull.Value Then
。。。
End If

16,549

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧