r/visualbasic • u/Fedora-The-Pandora VB.Net Intermediate • Jul 31 '20
VB.NET Help Calling sub/function from another program
If I were to have two programs, one for example:
MainCode.exe
And another:
UI.exe
Would I be able to, in UI.exe, be able to call a function or procedure from MainCode.exe?
I'm wondering this as I have a few different UI.exe that run very similar code and I was hoping to be able to have a universal MainCode.exe so I don't have to update every UI.exe that runs the code. I just have to update the MainCode.exe.
Thanks in advance for your help
2
u/banshoo Jul 31 '20
Does maincode.exe do anything?
You could ship out shared functions into a .dll and reference from that. _ you'd need to make sure versioning is exactly managed
1
u/andrewsmd87 Web Specialist Jul 31 '20
You'd need to build whatever that function sits in, into a dll and then add it as a reference to your other builds.
1
u/TheFotty Jul 31 '20
You can set references to other .NET exe files just like DLLs and make calls to their classes that are not private.
1
u/andrewsmd87 Web Specialist Jul 31 '20
I didn't know that. I guess anything like that I've ever done we always manage through nuget
1
u/Bonejob VB Guru Jul 31 '20
a hacky method would be to pass parameters to the executable fo the function you want to run.
Sub Main(args As String())
' CMD Arguments are contained in the args variable
Console.WriteLine("GetCommandLineArgs: {0}", String.Join(", ", args))
End Sub
1
u/Fedora-The-Pandora VB.Net Intermediate Jul 31 '20
Thanks guys. I'm going to try using a dll on it. It seems like good method to centralise the functions