If you have a class in a separate project, make sure the start up project has
a reference to that project in the references section of the solution tree
view.
'******code******
Public Class GetThis
Public Sub GetThisMessage(ByVal Message as String)
MessageBox.Show(Message)
End Class
'*****end of code******
The code is simpler that what you were trying to do.
Inside your button event handler, write the following code
'******code*******
Dim GT as New Proj1.GetThis
GT.GetThisMessage("Go Sox")
'*****end of code*******
The new keyword allows you to construct an instance of the class from the
class, which can be thought of as a template.
Once you have the instance, you can manage the properties of the instance,
and use its methods.
www.charlesfarriersoftware.com
"Tom" wrote:
> Hi All :
>
> I'm VB.Net Beginner I try to create object Dynamically :
>
> In my testing, I create 2 .net project
> One is MyApp (Type is windows application) with one button name "Button1"
> The another one is "prj01" (Type is Class libary) with one public Class name
> "dbLib"
>
> In this prj01.dbLib I create the simple code "
>
> Public Class dbLib
> Public Function SendMsg()
> MsgBox("a")
> End Function
> End Class
>
> and success to compile.
>
> In the MyApp.Form1 I create the following Simple code :
>
> Public Class Form1
> Inherits System.Windows.Forms.Form
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> Dim oCar As Object
> Dim ty As Type = Type.GetType("prj01.dbLib")
> oCar = Activator.CreateInstance(ty)
> oCar.SendMsg()
>
> End Sub
> End Class
>
> However , while I run the project , The object "ty" return NOTHING.
>
> And show error "Value Cannot be Null"
>
> How can fix it
>
> Thanks
>
>
>