使用新单词创建对象实例

时间:2012-11-27 22:48:12

标签: vb.net object nothing

以下代码在vb.net中生成这两个疑难解答提示 代码构建没有错误。本地窗口将OrderContext下的所有内容列为“Nothing”,0.0或“False”,当它停在试图设置address1的行上时。

“使用new关键字创建对象实例。”
“在调用方法之前检查以确定对象是否为null。”

Imports TPETest.com.nicusa.cdc.tpe2_ks

Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim PEService As New PaymentEngineService
        Dim OrderContext() As com.nicusa.cdc.tpe2_ks.WSOrderContext

        OrderContext.customer.address.address1 = "1233 Test Dr."
        OrderContext.customer.address.city = "City"
        OrderContext.customer.address.state = "KS"
        OrderContext.customer.address.zip = "66099"
        OrderContext.attributes.SetValue("John Smith", 1)
        OrderContext.attributes.SetValue("1233 Test Dr", 2)

1 个答案:

答案 0 :(得分:3)

您需要将Option Strict On放在模块的顶部。这有助于您确定将OrderContext声明为数组,并且作为数组,它没有customerattributes属性。

您可能想要输入

Dim OrderContext As New com.nicusa.cdc.tpe2_ks.WSOrderContext