|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Function and Class questionHello,
I have 2 questions maybe someone can answer. 1. On a function class when you return an item is it possible to return more than one and how is that done? Currently I am using for one Avariable = MyFunction() 2. In vb express is it possible to create an application that will allow a user to write an external class file to add onto it? What I am thinking is to allow the program to look for a class file, if it exists, call it. Thus can add one later if needed. Thanks Warex wrote:
> 1. On a function class when you return an item Once way would be to define a structure that holds the different return> is it possible to return more than one and how is that done? > Currently I am using for one > Avariable = MyFunction() values: Public Structure Results Dim Result1 As String Dim Result2 As Integer Dim Result3 As DateTime End Structure Then in your function, you create an instance of this structure and return that: Public Function GetValues() As Results Dim r As Results r.Result1 = "Some Value" r.Result2 = 123 r.Result3 = DateTime.Now Return r End Function Another way is to have multiple arguments passed in ByRef then change their values: Public Sub GetValues(ByRef R1 As String, ByRef R2 As Integer) R1 = "Some Value" R2 = 123 End Sub You could call it like this: Dim AString As String Dim AnInt As Integer GetValues(AString, AnInt) > Are you talking about a plug-in type system where 3rd parties can add> 2. In vb express is it possible to create an application that will allow a > user to write an external class file to add onto it? > What I am thinking is to allow the program to look for a class file, if it > exists, call it. Thus can add one later if needed. functionality to your app? Yes it can be done, search TheCodeProject.Com for plugin and you should find some hits. Basically, you would create an interface that serves as the "contract" that all plugins must implement, perhaps something like this: Public Interface IPlugin Public Function Execute() As Integer End Interface You would compile this into an assembly so that plug in writers can use it. The plug in writer would then Implement your plugin interface: Public Class MyPlugInClass Implements IPlugin Public Function Execute() As Integer 'do work here End Function End Class This would be compiled into a .dll as well and placed in a folder that your host app can access. Your host app would use the classes in System.Reflection to load these ..dll's at runtime and create instances of the IPlugin class from them. You then call the Execute function to get the plug-in to do its work. This is a very simple method and doesn't address unloading the plugins or updating them, but it should give you some things to search on. Good Luck, Chris THanks
Show quoteHide quote "Warex" <Igiveitalla***@juno.com> wrote in message news:ey$%23tvbCHHA.2328@TK2MSFTNGP02.phx.gbl... > Hello, > I have 2 questions maybe someone can answer. > > 1. On a function class when you return an item > is it possible to return more than one and how is that done? > Currently I am using for one > Avariable = MyFunction() > > > 2. In vb express is it possible to create an application that will allow a > user to write an external class file to add onto it? > What I am thinking is to allow the program to look for a class file, if it > exists, call it. Thus can add one later if needed. > > Thanks > >
appsetting in class doesn't work
RaiseEvent Howto Identify an Exception? Speeding up array/file loading Export function from VB.Net DLL vb 2005 standard question Can a base class implement a method on an interface for me? Dynamically iterating through log files passing parameter to class from application my class library doesn't contain an assembly - how to add an assem |
|||||||||||||||||||||||