E
eBob.com
I am trying to change some Structures to Classes. The Classes now
look like this ...
Public Class OneAttr
Public AttrName As String
Public Column As String
Public Caption As String
End Class
Public Class OneTable
Public ObjectName As String
Public TableName As String
Public NextIndex As Integer = -1
Public Attrs() As OneAttr
End Class
Public Class Product
Public ProdCode As String
Public NextTableIndex As Integer = -1
Public AtTables() As OneTable
End Class
I made the change, by the way, because I could not do the
initialization of the two fields you see initialized above when I was
using Structures.
But now I get an "object reference not set to an instance of an
object" Many, many hits in Google (this seems to be .Net's favorite
error message) but none were helpful.
Here's the code ...
Dim ThisProd As New Product
ThisProd.NextTableIndex = -1
....
If line.IndexOf("*OBJECT: ") = 0 Then
ThisProd.NextTableIndex = _
ThisProd.NextTableIndex + 1
TI = ThisProd.NextTableIndex 'shorthand
InTable = True
ReDim Preserve ThisProd.AtTables(TI)
ThisProd.AtTables(TI).NextIndex = -1 '< Error
ThisProd.AtTables(TI).ObjectName = _
line.Substring(9).Trim(" "c)
The error occurs on the statement which reads:
ThisProd.AtTables(TI).NextIndex = -1
This code worked when I was using Structures. TI is 0, so I think
that I have created the 1st element of ThisProd.AtTables().
I'll appreciate any and all help, pointers, or sympathy.
Thanks, Bob
look like this ...
Public Class OneAttr
Public AttrName As String
Public Column As String
Public Caption As String
End Class
Public Class OneTable
Public ObjectName As String
Public TableName As String
Public NextIndex As Integer = -1
Public Attrs() As OneAttr
End Class
Public Class Product
Public ProdCode As String
Public NextTableIndex As Integer = -1
Public AtTables() As OneTable
End Class
I made the change, by the way, because I could not do the
initialization of the two fields you see initialized above when I was
using Structures.
But now I get an "object reference not set to an instance of an
object" Many, many hits in Google (this seems to be .Net's favorite
error message) but none were helpful.
Here's the code ...
Dim ThisProd As New Product
ThisProd.NextTableIndex = -1
....
If line.IndexOf("*OBJECT: ") = 0 Then
ThisProd.NextTableIndex = _
ThisProd.NextTableIndex + 1
TI = ThisProd.NextTableIndex 'shorthand
InTable = True
ReDim Preserve ThisProd.AtTables(TI)
ThisProd.AtTables(TI).NextIndex = -1 '< Error
ThisProd.AtTables(TI).ObjectName = _
line.Substring(9).Trim(" "c)
The error occurs on the statement which reads:
ThisProd.AtTables(TI).NextIndex = -1
This code worked when I was using Structures. TI is 0, so I think
that I have created the 1st element of ThisProd.AtTables().
I'll appreciate any and all help, pointers, or sympathy.
Thanks, Bob