dll custom properties

  • Thread starter Thread starter Bryan V.
  • Start date Start date
B

Bryan V.

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
 
Hi Bryan,

What exactly do your mean by custom Properties? If you mean object properties, then it is just like in Vb, with a slightly different syntax.

Public Property MyProperty()
Get

End Get
Set(ByVal Value)

End Set
End Property

Regards,
Anand
VB.NET MVP
http://www.dotnetindia.com
 
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
 
* "Bob Powell said:
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)
^^^

'... As Integer'.

:-)
 
Sorry.. C# programmer disease :-)

--
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
 
Back
Top