Results 1 to 4 of 4

Thread: Setting a reference to variable

  1. #1
    Robert_Zenz's Avatar
    Robert_Zenz is offline VB.NET Forum Idol
    .NET Framework
    .NET 2.0
    Join Date
    Jun 2008
    Location
    Vienna, Austria
    Posts
    503
    Reputation
    339

    Setting a reference to variable

    Hello.

    I want to set a reference to a variable similar to ByRef.
    I'm using some global objects which are declared in each form like
    Code:
    Private myObj as Obj = GlobaleConstant.bla.globObj
    .

    The problem is, this is copying the momentary value of the object and is not setting a 'real' reference.
    Does anybody know how to set such a reference similar to a pointer?

    Thanks for the help,
    Bobby

  2. #2
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,201
    Reputation
    2369
    Reference type variables are references, value type variables are values, see Value Types and Reference Types

  3. #3
    Robert_Zenz's Avatar
    Robert_Zenz is offline VB.NET Forum Idol
    .NET Framework
    .NET 2.0
    Join Date
    Jun 2008
    Location
    Vienna, Austria
    Posts
    503
    Reputation
    339
    Hello and thanks for the reply.

    Means if I use my code above at a class it should work as a reference?

    Bobby

  4. #4
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,201
    Reputation
    2369
    Yes, class instances are object references.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking