1

The program is a booking system (amongst other things) for a holiday letting company. I am working on the screen where you can see properties and ammend them or add more (etc)

Okay so It works fine in my other cases, but this one it just doesn't want to accept...I expect it's something stupid. Basically In the initial loading of the entire program I filled the Data Tables with the relevant info and then accessed them when needs be, in this case I am in the Form Properties and want to access Bookings (Which were made in FrmBookings) to see when the property is next booked to have guests in.

Dim Intcounter As Integer = 0
Dim NumberBookingRecords As Integer = BookingsNumRecs

Dim PropertyName As String
Dim PropertyFromBookings As String


Do

    PropertyName = DTProperties(Intcounter)("Property Name").ToString
    PropertyFromBookings = (DTBookings(NumberBookingRecords)("Property").ToString)

    If PropertyName = PropertyFromBookings Then

        lblDateOfArrival.Text = (DTBookings(NumberBookingRecords)("Arrival").ToString)
        Intcounter = Intcounter + 1

    Else

        If Not NumberBookingRecords = 0 Then

            NumberBookingRecords = NumberBookingRecords - 1

        Else

        End If

    End If


Loop Until Intcounter >= intNumPropertyRecs

However when I get to PropertyFromBookings = (DTBookings(NumberBookingRecords)("Property").ToString) it tells me that it could not be set to an instance of an object...no matter what I try an access from DTBookings I get the same response.

This is in the initial load form at the opening of the program

Dim FSBookings As New FileStream(strFileNameBookings, FileMode.OpenOrCreate, FileAccess.Read)

Application.DoEvents()

If FileLen(strFileNameBookings) > 0 Then
    DTBookings.ReadXmlSchema(strFileNameBookings)
    DTBookings.ReadXml(strFileNameBookings)
    BookingsNumRecs = DTBookings.Rows.Count
    intCurrRec = 1
Else
End If

FSBookings.Close()
blnStopAuto = True
blnStopAuto = False
4

1 回答 1

0

根据您的代码示例,DTBookings()是一个函数调用。这里有两种可能。任何一个:

  1. 该函数的结果是Nothing,并且当您尝试使用 Nothing 时,就好像那里有一个实际的对象一样,(在这种情况下,当您尝试查找("Property")索引器时)您会得到那个异常,或者......
  2. ("Property") 索引的结果返回 Nothing,在这种情况下,当您尝试调用 .ToString() 方法时会出现该异常。
于 2013-01-26T13:51:36.403 回答