Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Posted

I believe this is what you are looking for.

'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

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...