John500
asked on
How to add a file reference to VB project
Greetings,
I have a VB project that contains about 20 vb files. Each file handles a particular function like importing a file, or changing an asset location etc, etc.
I'm adding another file to perform a function that closely relates an existing file/function. How do I make reference to this file so I can use a particular routine in that file?
Considering the picture below, I would expect a dropdown somewhere that would provide a way to reference project files.
How would I do this if the file name I need to reference is called AssetChangeDept.vb ??
Thanks!
adding-reference-example.JPG
I have a VB project that contains about 20 vb files. Each file handles a particular function like importing a file, or changing an asset location etc, etc.
I'm adding another file to perform a function that closely relates an existing file/function. How do I make reference to this file so I can use a particular routine in that file?
Considering the picture below, I would expect a dropdown somewhere that would provide a way to reference project files.
How would I do this if the file name I need to reference is called AssetChangeDept.vb ??
Thanks!
adding-reference-example.JPG
ASKER
Sorry if I wasn't clear on the project configuration. The twenty files I spoke of are part of the existing project. Thus, the file I'm adding will be file 21 and let's say the file I want to barrow from is file 5.
Since this file 21 handles a completely separate task I don't want to add the code to file 5. I just want to make reference to the routine in file 5.
See what I mean?
Since this file 21 handles a completely separate task I don't want to add the code to file 5. I just want to make reference to the routine in file 5.
See what I mean?
I think i understand what you want...will you need runtime values from file example file 5? Meaning will it be running live data and when you access it, the success of file 21 is dependent upon that data? or will you be passing the values to file 5 from file 21? if so, could you just create an instance of form 5 within form 21 (OOP) to use its methods?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I may have misunderstood ...
This file - AssetChangeDept.vb - Does it contain a namespace?
If so you need to :
Imports AssetChangeDeptNameSpace.F ileNameCla ssName
Does this make sense or ???
This file - AssetChangeDept.vb - Does it contain a namespace?
If so you need to :
Imports AssetChangeDeptNameSpace.F
Does this make sense or ???
ASKER
I won't be needing any runtime values. I just need to access the methods or functions from file - AssetChangeDept.vb
File AssetChangeDept.vb definitely contains a class called 'AssetChangeDept'
This class has a particular function I want to use - Private Sub MoveAsset()
The constructor for the class looks like this:
Public Sub New(ByVal f1 As AssetTrack)
Call InitializeComponent()
form1 = f1
End Sub
I guess I need to declare an instance of the class in my new file. However, I don't need or want the Form that comes with this class. I guess I have two choices at this point:
1) Create an overloaded constructor that doesn't take a Form (how would that look? )
2) Be redundant and forget this class - just barrow all the code in the new file.
If I did create a new constructor, how would I do it? The call to InitializeComponent() basically initializes all the buttons and objects of a Form I'm not even using:
Public Sub New()
????????
End Sub
Then what in my new file?
Thanks
File AssetChangeDept.vb definitely contains a class called 'AssetChangeDept'
This class has a particular function I want to use - Private Sub MoveAsset()
The constructor for the class looks like this:
Public Sub New(ByVal f1 As AssetTrack)
Call InitializeComponent()
form1 = f1
End Sub
I guess I need to declare an instance of the class in my new file. However, I don't need or want the Form that comes with this class. I guess I have two choices at this point:
1) Create an overloaded constructor that doesn't take a Form (how would that look? )
2) Be redundant and forget this class - just barrow all the code in the new file.
If I did create a new constructor, how would I do it? The call to InitializeComponent() basically initializes all the buttons and objects of a Form I'm not even using:
Public Sub New()
????????
End Sub
Then what in my new file?
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I ended up going an entirely different route which relied more on the database stored procedures than the VB code. Take a look at this question if you folks get a chance:
https://www.experts-exchange.com/questions/23918454/Correct-way-to-initialize-a-ListBox-during-Form-Load.html
https://www.experts-exchange.com/questions/23918454/Correct-way-to-initialize-a-ListBox-during-Form-Load.html
right click and Add Reference...
Most likely go to Browse and get the .exe or dll...but .vb file isn't compiled, so that's not going to work...if you want to use the vb file, then you could
In solutions Explorer pane,
right click and add existing Item...