"return a User object"

eramgarden

Contributor
Joined
Mar 8, 2004
Messages
579
I have a function that returns a string array. A developer said I can do this:

return a User object. As things get more complex, add properties to that user object.


Anyone has an exmple of creating and returning a userobject?
 
I believe this is what you are looking for.
Visual Basic:
'User Object
Public Class UserObject
    Dim sValue as String    'Local copy of global value

    Sub New(ByVal str as String)
        sValue = str
    End Sub
    Sub New ()
        New(New String("MyNewValue")
    End Sub

    Public Property MyValue() As String
        Get
            Return sValue
        End Get
        Set(ByVal value As String)
            sValue = value
        End Set
    End Property
End Class

'Form1 Code
Dim mObj as UserObject

mObj = MyFunction(False)

Public Function MyFunction(ByVal bln as Boolean) as UserObject
    Dim localObj as UserObject
    If bln = True Then
        localObj.Value = "True"
    Else
        localObj.Value = "False"
    End If
    Return localObj
End Function
 
Back
Top