缺少节点的vb.net条件 [英] vb.net condition with missing nodes

查看:59
本文介绍了缺少节点的vb.net条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨。

我对这个话题很新。

我在visual express basic 2008上工作。

I work on visual express basic 2008.

我已经构建了一个使用Web服务的Windows窗体。我确实设法获得了预期的信息,这些信息被填充到几个文本框和datagridview中。

I have built a Windows Form which uses a webservices. I do manage to get the expected information, those ones are filled into several textboxes and datagridview.

但是我有关于缺少节点的问题,例如:

However I have an issue regarding missing nodes, for instance :

txtReference是我的文本框之一,我写道:

txtReference is one of my textbox, i wrote :

 

txtReference.text = MyResult.Product(0).ReferenceNumber( 0).value

txtReference.text = MyResult.Product(0).ReferenceNumber(0).value

 

当服务为产品ReferenceNumber提供xml节点时,它工作正常,但是当产品没有ReferenceNumber时,当然我没有节点,我收到错误信息

When the service provides a xml node for the product ReferenceNumber it works fine, but when the product has no ReferenceNumber, of course I have no node and I get an error message

如何创建一个条件:如果没有节点不写入txtReference.text ...

How can I create a condition like : if there is no node do not write into txtReference.text...

我希望这很清楚,

Rgds

 

 

 

 

 

推荐答案

嗯,你没有表明MyResult.Product是什么类型,但是"(0)"看起来像索引一个集合所以你应该能够使用例如

Well you haven't shown what kind of type MyResult.Product is but "(0)" looks like indexing a collection so you should be able to use e.g.

如果MyResult.Product(0)IsNot Nothing AndAlso MyResult.Product(0).ReferenceNumber(0)IsNot Nothing Then

If MyResult.Product(0) IsNot Nothing AndAlso MyResult.Product(0).ReferenceNumber(0) IsNot Nothing Then

   txtReference.text = MyResult.Product(0).ReferenceNumber(0).value

   txtReference.text = MyResult.Product(0).ReferenceNumber(0).value

结束如果

如果这没有用,那么告诉我们更多详细信息,如MyResult的类型/类定义以及Product和ProductReferenceNumber等子属性。

If that does not help then show us more details like the type/class definition of MyResult and sub properties like Product and ProductReferenceNumber.


这篇关于缺少节点的vb.net条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆