在 VB.Net 中使用 Null
我正在从 HP 质量中心调用 OTA API,其中一个调用需要发送 NULL。
这是实际的代码行:
stepF.AddItem(NULL)
这在 VBA 和 VB6 中完美运行,但 VB.NET 不接受 Null。有人知道如何解决这样的问题吗?
I am calling the OTA API from HP Quality Centre and one of the calls requires sending a NULL.
This is the actual line of code:
stepF.AddItem(NULL)
This works perfectly in VBA and VB6 but VB.NET doesn't accept Nulls. Anyone know how to fix such an issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要使用
Nothing
,它是 大部分等效 到null
。You need to use
Nothing
, which is mostly equivalent tonull
.Nothing
是 VB.Net 中大多数引用类型的 Null 值,我建议您查看 MSDN 或 这篇文章,如果您使用的 API 是 .Net Web 服务,您可以能够对 WSDL 进行部分分类并进行修复,尽管听起来好像您不是。Nothing
is the Null value for most reference types in VB.Net, I would recommend taking a look atNullable(Of T)
on either MSDN or some good information about it in this SO post, if the API you are using is a .Net web service you may be able to partial class the WSDL and fix although it sounds as though you are not.正确使用的值是
System.DBNull.Value
。即使文档告诉我们这通常用于数据库空值,它也代表没有值,否则
NULL
。The correct value to use is
System.DBNull.Value
.Even if the documentation tells us that this is generally used for database null values, it represent the absence of value, otherwise
NULL
.您应该使用 DBNull
You should use DBNull