Ok, unfortanly I don't have vb6 installed on my current pc. (first time in a VERY long time that I never go around to setup + install of Vb6).
however, I do have ms-access, and VBA - and their event models should be simular.
I find that from VBA, I can use a vb.net class, and if I launch forms from that VBA "com" object, the .net form(s) are able freely to launch. And the .net forms work fine - including display of msg box or whatever.
However, I do no launch the .net form(s) as dialog, and you probably don't want to do that, since that would in theory "freeze" the vb6/vba UI from allowing call backs (if you have any).
So, I can't say the above helps a whole lot, but as long as the calling code (VBA/VB6) does not wait, or get stuck in a dialog form (from .net), then you should be ok.
In other words, don't launch/show/display the .net forms as dialog, and don't let the VB6 code "halt" when it launches the .net forms (such as waiting for a .net dialog and waiting to continue).
However, I find that even when I launch the .net form as dialog, (and VBA code halts, waits), I find that the .net form and UI - and even use of msgbox (or other dialog forms) works just fine. And when I close the .net form, the calling VBA code can thus continue.
I don't think the above behavior would change much in regards to the client being VB6.
So, say I build this simple vb.net class
Imports System.Runtime.InteropServices
<ClassInterface(ClassInterfaceType.AutoDual)>
Public Class Class1 : Implements IDisposable
Private disposedValue As Boolean
Dim f1 As New Form1
Public Sub HelloWorld()
MsgBox("Hello from .net!")
End Sub
Public Function MyMultiply(x As Double, y As Double) As Double
Return x * y
End Function
Sub ShowForm()
f1.Show()
End Sub
Sub CloseForm()
f1.Close()
End Sub
Sub ShowFormDialog()
f1.ShowDialog()
End Sub
Protected Overridable Sub Dispose(disposing As Boolean)
If Not disposedValue Then
If disposing Then
' TODO: dispose managed state (managed objects)
f1.Close()
f1.Dispose()
End If
' TODO: free unmanaged resources (unmanaged objects) and override finalizer
' TODO: set large fields to null
disposedValue = True
End If
End Sub
' ' TODO: override finalizer only if 'Dispose(disposing As Boolean)' has code to free unmanaged resources
' Protected Overrides Sub Finalize()
' ' Do not change this code. Put cleanup code in 'Dispose(disposing As Boolean)' method
' Dispose(disposing:=False)
' MyBase.Finalize()
' End Sub
Public Sub Dispose() Implements IDisposable.Dispose
' Do not change this code. Put cleanup code in 'Dispose(disposing As Boolean)' method
Dispose(disposing:=True)
GC.SuppressFinalize(Me)
End Sub
End Class
Ok, force the project to x86 (this is a very good idea).
Now, in vba/access, set a reference to the above object.
This code (vba), works just fine.
Private Sub Command0_Click()
Dim cls As New ComTest.Class1
cls.HelloWorld
cls.ShowFormDialog
MsgBox "wait"
cls.Dispose
End Sub
so, when I run, the first method (Hello world runs), and I see this in ms-access.
And then ok, and then the next method (to display .net form as dialog) then shows.
And all of the buttons, and UI on that form - even as dialog shows.
And if I close form, then VBA code continues and we are done.
Regards,
Albert D. Kallal (Access MVP 2003-2017)
Edmonton, Alberta Canada