Hank
Hank

Reputation: 2646

Create a subroutine in a VB.Net exe that is callable from another program

Is it possible to create a subroutine in a VB.Net exe that is callable from another program(not VB.Net)? I am aware that you can do this with an assembly(dll), but can you do this in an exe as well?

[Edit]This VB.Net exe will already be running when called.

[Edit2] VB.Net program, these compile to become BA_SyncNet.exe - Form1.vb

Public Class Form1
    ...
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ...
    End Sub
End Class

VB.Net program - Helloworld.vb

Namespace MapInfoBA.MiProBA.SamplesBA
    Public Class HelloWorld

        Public Shared Sub SayHello(ByVal s As String)
            System.Windows.Forms.MessageBox.Show("Hello, " + s)
        End Sub

    End Class
End Namespace

Calling program ba.mbx uses:

Declare Method SayHello Class "MapInfoBA.MiProBA.SamplesBA.HelloWorld"  Lib "BA_SyncNet.exe" (ByVal strName As String)

Sub Main()
    Call SayHello("World")
End Sub

Kind Regards

Upvotes: 1

Views: 1380

Answers (2)

Arvie
Arvie

Reputation: 47

Create a file (let's say, DoThisVBNet.txt) using MapBasic program.

Then your vb.net program checks the file from time to time. The vb.net program will do a task (in your case, call a subroutine) based on the DoThisVBNet.txt file.

However, Problem may occur on accessing the file since two programs are using it, to fix this, use Registry instead of File.

Upvotes: 0

Joel Coehoorn
Joel Coehoorn

Reputation: 416141

I am aware that you can do this with an assembly

An .exe is a kind of assembly. So, yes.

Upvotes: 2

Related Questions