|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Trouble Instanciating StructuresModule. When I run the Main Subroutine it errors out when I try to assign a value to the Id1 array with "Object not set to instance..." blah blah - even though I have clearly just instanciated it in the previous line. Any ideas? Thanks, John (see code below) Module Main Structure zFuheader Dim Id1() As Byte Dim Id2() As Byte Dim Id3() As Byte Dim Id4() As Byte End Structure Sub Main() Dim zHeader As zFuheader Try zHeader = New zFuheader zHeader.Id1(1) = Byte.Parse("1") Catch ex As Exception Console.Writeline(ex.Message) End Try End Sub End Module It's not the structure that needs instantiated, it's the array. This should
work: Dim zHeader As zFuheader zHeader.Id1 = New Byte() {1} Tony Show quoteHide quote "redeagle" wrote: > I'm having trouble assigning values to a structure that has been created in a > Module. When I run the Main Subroutine it errors out when I try to assign a > value to the Id1 array with "Object not set to instance..." blah blah - even > though I have clearly just instanciated it in the previous line. > > Any ideas? > > Thanks, > John (see code below) > > Module Main > > Structure zFuheader > Dim Id1() As Byte > Dim Id2() As Byte > Dim Id3() As Byte > Dim Id4() As Byte > End Structure > > Sub Main() > Dim zHeader As zFuheader > Try > zHeader = New zFuheader > zHeader.Id1(1) = Byte.Parse("1") > Catch ex As Exception > Console.Writeline(ex.Message) > End Try > End Sub > > End Module Excellent! That does the trick. Thanks Tony.
Show quoteHide quote "tlkerns" wrote: > It's not the structure that needs instantiated, it's the array. This should > work: > > Dim zHeader As zFuheader > zHeader.Id1 = New Byte() {1} > > Tony > > "redeagle" wrote: > > > I'm having trouble assigning values to a structure that has been created in a > > Module. When I run the Main Subroutine it errors out when I try to assign a > > value to the Id1 array with "Object not set to instance..." blah blah - even > > though I have clearly just instanciated it in the previous line. > > > > Any ideas? > > > > Thanks, > > John (see code below) > > > > Module Main > > > > Structure zFuheader > > Dim Id1() As Byte > > Dim Id2() As Byte > > Dim Id3() As Byte > > Dim Id4() As Byte > > End Structure > > > > Sub Main() > > Dim zHeader As zFuheader > > Try > > zHeader = New zFuheader > > zHeader.Id1(1) = Byte.Parse("1") > > Catch ex As Exception > > Console.Writeline(ex.Message) > > End Try > > End Sub > > > > End Module
Conversion
DLL created in .NET cannot use? (Inno Setup) Drawing images in different shapes VB.Net Merging Datasets Incorrect behavior of IIf in VB.NET (.NET Framework 1.1 SP1) problem in converting to C# Catch reference error how? Getting error LIBCMT.lib(tidtable.obj) : error LNK2005: __encode_pointer already defined in atlmincr database connection Remove x number of charaters from string. Vb.net |
|||||||||||||||||||||||