Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pass parameters between projects?

Status
Not open for further replies.

lydro

Programmer
Mar 7, 2005
36
CA
In my solution explorer, I have three projects, I want to pass parameters from one project to others? how can I do it? I'm using vb.net.

thanks.
 
Think Object Orientation.

In order for project A to talk to project B, project A needs a reference to project B.

Project B will need a Public class that an object from Project A can see.

for example:
Code:
'Project B
Public class MyClass
  Public Function DoThing(Value as string)
    '...
  End Sub
End class

In Project A we add a reference to Project B and then we can use it:
Code:
'Project A
Public class MyClassA
  Public Sub DoSomething()
    dim x as ProjectB.MyClass
    x.DoThing("Doing something in the class defined in Project B")
  End Sub
End Class

-Rick

----------------------
[banghead]If you're about to post an ASP.Net question,
please don't do it in the VB.Net forum[banghead]

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
I tried your code, but it returned nothing to the it, it should returns a value, could you please help me look at the code?

In ProjectB
public server as string = "testing"

Public Class _myClass

Private t As String
Property test() As String
Get
Return t
End Get
Set(ByVal Value As String)
t = server
End Set
End Property

End Class

In projectA
dim s as string
dim a a new projectb._myclass
s=a.test()
messagebox.show(s)

when I run it, the messagebox is empty, why I can't get the value "testing" from projebB?
 
You'll need to do one of the following:
Code:
'Project A
dim s as string
dim a as New ProjectB._myclass
s=a.Server 'Server is a public variable on _myclass
messagebox.show(s)

or to get your property:
Code:
'Project B
Public Class _myClass

    Private t As String
    Public Property test() As String
        Get
            Return t
        End Get
        Set(ByVal Value As String)
            t = server
        End Set
    End Property

End Class

and

Code:
'In Project A
dim s as string
dim a as New projectb._myclass
a.test = "testing" 'test is a public property on _myclass
messagebox.show(a.test)

-Rick

----------------------
[banghead]If you're about to post an ASP.Net question,
please don't do it in the VB.Net forum[banghead]

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
Like ThatRickGuy says -- in order to pass a value to anything, you need an instance of it. And in order to create an instance (think "new"), you need to be able to see what you're creating (think "reference").

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top