[RESOLVED] Issue pssing data between VB 6.0 and .NET
I have a VB 6.0/.NET program combination that I'm trying to return data back to VB 6.0. I'm pretty sure I'm missing something simple.
This is the VB 6.0 program:
Private Sub cmdTestIt_Click()
Dim strX As String
strX = "1234"
Dim mImageMainNet As New ImageMainNet.Main
mImageMainNet.TestIt (strX)
MsgBox strX
End Sub
This is the .NET program:
<ComClass(Main.ClassID, Main.InterfaceID, Main.EventsID)>
Public Class Main
Public Sub TestIt(ByRef strX As String)
strX = "Test"
End Sub
End Class
I'm expecting the test "Test" to come back but it remains "1234". I know I'm hitting the .NET program via stepping through the code. I don't see what I'm missing. I thought ByRef would do it. Any suggestions?
ByRef would be right. If you were to pass it ByVal, it should behave the way it is behaving. However, .NET and VB6 changed the default passing behavior. In .NET it is ByVal, which means that in VB6 it is ByRef (I don't remember, I just remember that the two languages swapped the default).
I don't understand why your .NET method is a sub routine. It sounds like you expect to pass a value from your VB6 application, have your VB.NET application transform the value, and then the VB.NET application returns the transformed value. I don't have much experience with inter-application communication like this, but I'd expect something like this:
Code:
Public Function TestIt(ByVal strX As String) As String
strX = "Test"
Return strX
End Function