Passing Vb equivilent of "structs" between forms

  • Thread starter Thread starter Chris Strug
  • Start date Start date
C

Chris Strug

Hi,

I'm working with VB 2005.net and have managed to get my head around passing
values between forms by creating properties of the relevant form classes.

However, say that I have a number of values which I wish to exchange (for
example, an employee record, name, position, etc). At the minute I'm using a
seperate property to for each "field".

I was wondering, is there a way to collate all the fields into one "object"
and use that as a property? I'm reminded of a "struct" from my C days and
was wondering if VB provided anything similar?

Any and all advice, tips, links and abuse are gratefully received.

Thanks

Chris,
 
However, say that I have a number of values which I wish to exchange (for
example, an employee record, name, position, etc). At the minute I'm using
a seperate property to for each "field".

Properties of what? Each Form? Or a Class, each instance of which
represents an Employee?
I was wondering, is there a way to collate all the fields into one
"object" and use that as a property?

You could go with a Structure (the direct equivalent of struct) but,
personally, I'd jump straight in with a Class. Maybe something like this
(only with [lots] more Properties):

Class Employee
' ? Inherits BaseClassForAnyPerson

Private m_EmpNumber As String = Nothing

Public ReadOnly Property EmpNumber() As String
. . .
End Property

Public Sub LoadFrom( ByVal source As ... )
m_EmpNumber = source.Something
. . .
End Sub

Public Sub SaveTo( ByVal source As ... )
. . .
End Sub

Public Sub New( ByVal source As ... )
Me.LoadFrom( source )
End Sub

End Class

HTH,
Phill W.
 
Back
Top