Having problem in assigning value to data structure array

Hi all, in VB6 the following statement wont gives me NullReferenceException, but in VB.net it does, can anyone tell me how to assign value into a variable within a data structure? Helps!

Dim lTemp As Integer = 5

gCI.CICC(gCICCTotal).CCId = lTemp

[264 byte] By [BiBiMeiMei] at [2007-12-24]
# 1

Are you refering to something like this?

That really is not enough information. It also depends on the access level, Public Friend etc.

Partial Class Struct

Inherits System.Web.UI.Page

Friend Structure MyStructure

Friend Id As Integer

Friend Name As String

End Structure

Protected Sub Sample()

Dim itm As New MyStructure

itm.Id = 0

End Sub

End Class

mokeefe at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2
Note the New keyword. It is instantiating the structure.
mokeefe at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3

Declare the structure in this way

Public Structure st

Public str As String

Public Sub New(ByVal value As String)

str = value

End Sub

End Structure

Decalre it like this.

dim x as new st("xyx")

st.str = "abc"

PrasantSwain at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 4
Arrays inside structures need to be initialized before they can be used. Try something like this:

Module Module1
Public Const CCICSize As Integer = 100

Public Structure CIStruct
Dim CCIC() As Integer
Public Sub Initialize()
ReDim CCIC(CCICSize - 1)
End Sub
End Structure

Public gCI As CIStruct
End Module

...somewhere...
gCI.Initialize()

nobugz at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...