Re: dll custom properties

From: Bob Powell [MVP] (bob_at__spamkiller_bobpowell.net)
Date: 07/12/04


Date: Mon, 12 Jul 2004 11:29:14 +0200

VB.NET is object oriented and requires that properties are members of a
class. You will create a class as a container for the properties and declare
them in much the same way.

Generally, a class with properties must be instantiated before the
properties can be used so you might do something like....

public class MyClass

    private _int as Integer

    public property MyInt as Integer
      get
        return _int
      end get
      set(byval value)
        _int=value
      end set
    end property

end class

In your application that uses the DLL you create a new instance of "MyClass"
and adjust it's properties...

Imports MyDllNamespace

public class someclass
    'create an instance of the class and hence it's properties
    private c as MyClass=new MyClass()

    public sub someSub()
      'use the class properties
      c.MyInt=10
    end sub
end class

You can create classes that have static or shared properties. These don't
require an instance of the containing class and can be used as global
variables. I guess this was what you are referring to when you asked the
original question. Although this works, it's not a particularly good design
practice and you should begin thinking more in object-oriented terms where
properties are members of classes that have a lifetime.

-- 
Bob Powell [MVP]
Visual C#, System.Drawing
The Image Transition Library wraps up and LED style instrumentation is
available in the June of Well Formed for C# or VB programmers
http://www.bobpowell.net/currentissue.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm
The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://bobpowelldotnet.blogspot.com/atom.xml
"Bryan V." <chaoticdriver@hotmail.com> wrote in message
news:O9eBTd8ZEHA.2488@tk2msftngp13.phx.gbl...
> Hello,
> I am a long time VB6 user, and am trying to make a VB.Net DLL. I am having
> one problem using the new language, how do I add custom properties to a
DLL?
> The properties that a user can adjust at design time.
>
> Thanks!
> Bryan
>
>


Relevant Pages

  • Re: Static Methods
    ... The private keyword refers to access or visibility of members and classes ... Derived classes may not access the data or member. ... Answer those GDI+ questions with the GDI+ FAQ ... > When static is applied to data, if methods access the private data, the data> is required to be static. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Protected static members, abstract classes, object composition vs. subclassing
    ... > var goodBoy = new myClass(); ... privileged object members - in the most common case to public object ... actual caller, we cannot simply ask to caller "Who's your master?" ...
    (comp.lang.javascript)
  • Re: C# confusion
    ... MyClass" then you will never create an instance of MyClass on the heap, ... so any instance members you declare in MyClass will never exist. ... of memory: not the stack and not the heap, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: C# confusion
    ... associated with it on the heap (including static variables). ... If you create instances of MyClass, ... static keyword; This one has been hitting me like a hammer on the head. ... Static members are associated with the type itself rather than with any ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: C# confusion
    ... If you create instances of MyClass, ... you are allocating an area of memory for the data segment for each ... data members are initialised upon first reference of the class. ... static keyword; This one has been hitting me like a hammer on the ...
    (microsoft.public.dotnet.languages.csharp)