|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Structures inside structuresCould somebody perhaps let me know, what the equivalnet code in VB.Net for
this C# example. public struct MyStruct { public MyChild[] AsChild; public int nOther; public string nInfo; } MyChild structure: private int nINTA; private string cSomeString; Pretty much the same...
Public Structure MyStruct Public Mychild() As Child Public nOther As Integer Public nInfo As String End Structure Structure Child Private nINTA As Integer Private cSomeString As String End Structure Rob Show quoteHide quote "Andrew" <And***@discussions.microsoft.com> wrote in message news:E2BB0277-1117-4D40-ABB4-791DC7997B2F@microsoft.com... > Could somebody perhaps let me know, what the equivalnet code in VB.Net for > this C# example. > > public struct MyStruct > { > public MyChild[] AsChild; > public int nOther; > public string nInfo; > } > > > MyChild structure: > > private int nINTA; > private string cSomeString; > I thought so.
So, adding to this example, is this proper way to return the child structure. Dim Parent As New MyStruct Dim Child As New Child Child = Parent.MyChild Show quoteHide quote "roidy" wrote: > Pretty much the same... > > Public Structure MyStruct > Public Mychild() As Child > Public nOther As Integer > Public nInfo As String > End Structure > > Structure Child > Private nINTA As Integer > Private cSomeString As String > End Structure > > Rob > > "Andrew" <And***@discussions.microsoft.com> wrote in message > news:E2BB0277-1117-4D40-ABB4-791DC7997B2F@microsoft.com... > > Could somebody perhaps let me know, what the equivalnet code in VB.Net for > > this C# example. > > > > public struct MyStruct > > { > > public MyChild[] AsChild; > > public int nOther; > > public string nInfo; > > } > > > > > > MyChild structure: > > > > private int nINTA; > > private string cSomeString; > > > Yep but don`t forget that MyChild is an array of type Child and must be
declared to the size you need:- ReDim Parent.MyChild(10) and then you must specify which one you want Child to become:- Child = Parent.MyChild(0) So the whole code looks like:- Public Structure MyStruct Public Mychild() As Child Public nOther As Integer Public nInfo As String End Structure Structure Child Private nINTA As Integer Private cSomeString As String End Structure Dim Parent As New MyStruct Dim Child As New Child ReDim Parent.Mychild(10) <--- However many you need Child = Parent.Mychild(0) <--- Index of the one you want to pass to Child Rob Show quoteHide quote "Andrew" <And***@discussions.microsoft.com> wrote in message news:18C088EC-23F5-434C-9BA5-79A542D5A848@microsoft.com... > I thought so. > So, adding to this example, is this proper way to return the child > structure. > > Dim Parent As New MyStruct > Dim Child As New Child > > Child = Parent.MyChild > Ah, that's why I was getting array type errors. You wouldn't happen to be
able to tell me where you learned that from? I have one more if you don't mind. How can I return the whole Parent.Mychild structure into another structure like this: Dim Husband As New MyStruct Dim Wife As New MyStructA (imagine Mystruct is is the same as Mystruct) Wife.MyChild = Husband.MyChild Show quoteHide quote "roidy" wrote: > Yep but don`t forget that MyChild is an array of type Child and must be > declared to the size you need:- > > ReDim Parent.MyChild(10) > > and then you must specify which one you want Child to become:- > > Child = Parent.MyChild(0) > > So the whole code looks like:- > > Public Structure MyStruct > Public Mychild() As Child > Public nOther As Integer > Public nInfo As String > End Structure > > Structure Child > Private nINTA As Integer > Private cSomeString As String > End Structure > > Dim Parent As New MyStruct > Dim Child As New Child > ReDim Parent.Mychild(10) <--- However many you need > > Child = Parent.Mychild(0) <--- Index of the one you want to pass to > Child > > > > Rob > > > "Andrew" <And***@discussions.microsoft.com> wrote in message > news:18C088EC-23F5-434C-9BA5-79A542D5A848@microsoft.com... > > I thought so. > > So, adding to this example, is this proper way to return the child > > structure. > > > > Dim Parent As New MyStruct > > Dim Child As New Child > > > > Child = Parent.MyChild > > > > >
Cannot update Access Database
Get url for pdf file from AxSHDocVw.AxWebBrowser Attribute wanted how to remove a programmatically created DateTimePicker Application development pointers Resizing the click area of a checkbox. How to add control/component to the IDE toolbar why not inherit from type 'b(Of a)' Convert an untyped Data Table to a typed Data Table Trouble with Cross thread control access |
|||||||||||||||||||||||