Take a look at this video https://www.youtube.com/watch?v=yp5kQtQwPNQ&feature=youtu.be
sashaw2
Posts
-
Planetary orbit problems again -
Is it possible to pass a collection by reference from vb6 to vb.net?Thanks for your help. I was able to get it working as you described.
-
Is it possible to pass a collection by reference from vb6 to vb.net?It does not need to replace the collection. It will need to make changes to the collection in vb.net and have those changes reflected in the vb6 collection.
-
Is it possible to pass a collection by reference from vb6 to vb.net?I have created a collection class in vb.net to pass a collection from vb.net to vb6 and everything works great. I am now trying to send a collection to a function by reference. The collection is created in vb6 but the function is in a class in vb.net. The function needs to be able to update the collection (thus byRef).
-
VB6 to VB.Net COM Interface HelpI read setting the parameter ByRef and not ByVal would work but wasn't sure how to set it up. A little tweaking and the vb.net code looks like this:
_
Public Class clsValues#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "095dc64d-141f-46f9-9af2-1c5e633b459b"
Public Const InterfaceId As String = "86ec1f14-1ef4-446d-9172-b92cf260cd16"
Public Const EventsId As String = "1605e412-8b11-4ee0-a34c-9ec04464737f"
#End Region' A creatable COM class must have a Public Sub New() ' with no parameters, otherwise, the class will not be ' registered in the COM registry and cannot be created ' via CreateObject. Public Sub New() MyBase.New() End Sub Private mSingleString As String Public Property SingleString() As String Get Return mSingleString End Get Set(ByVal value As String) mSingleString = value End Set End Property Private mStringArray As String() Public Function StringArray() As String() Return mStringArray.ToArray End Function Public Function StringArray(i As Short) As String Return mStringArray(i) End Function Public Sub SetStringArray( ByRef value As String()) mStringArray = value End Sub
End Class
The final vb6 code looks like this:
Option Explicit
Private Sub btnTest_Click()
Dim x As Integer
Dim strTest(4) As String
strTest(1) = "abc"
strTest(2) = "def"
strTest(3) = "ghi"
strTest(4) = "jkl"On Error GoTo err1 Dim clsTest As comtest.clsValues Set clsTest = New comtest.clsValues clsTest.SingleString = "this is my string" clsTest.SetStringArray strTest MsgBox "Single string = " & clsTest.SingleString, vbInformation, "Test" For x = 1 To UBound(clsTest.StringArray) 'clsTest.UboundStringArray MsgBox "Multi string " & x & " = " & clsTest.StringArray\_2(x), vbInformation, "Test" Next x Exit Sub
err1:
MsgBox "Error: " & Err.Number & vbCrLf & Err.Descrip -
VB6 to VB.Net COM Interface HelpThank you for the reply It is a typo but this is where the error occurs, see error message at top of message after correction.
-
VB6 to VB.Net COM Interface HelpWhy do i get the error - "Function or interface marked as restricted, or the function uses an Automation type not supported in Visual Basic", when I try to pass a String array from vb6 to a class:Property string array in vb.net? This is the vb6 code:
Option Explicit
Private Sub btnTest_Click()
Dim strTest(4) As String
strTest(1) = "abc"
strTest(2) = "def"
strTest(3) = "ghi"
strTest(4) = "jkl"On Error GoTo err1 Dim clsTest As ComTest.clsValues Set clsTest = New ComTest.clsValues clsTest.SingleString = "this is my string" clsTest.stringArray = strTest ' <<
This is the vb.net class
Imports System.Runtime.InteropServices
_
Public Class clsValues#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "095dc64d-141f-46f9-9af2-1c5e633b459b"
Public Const InterfaceId As String = "86ec1f14-1ef4-446d-9172-b92cf260cd16"
Public Const EventsId As String = "1605e412-8b11-4ee0-a34c-9ec04464737f"
#End Region' A creatable COM class must have a Public Sub New() ' with no parameters, otherwise, the class will not be ' registered in the COM registry and cannot be created ' via CreateObject. Public Sub New() MyBase.New() End Sub Private mSingleString As String Public Property SingleString() As String Get Return mSingleString End Get Set(ByVal value As String) mSingleString = value End Set End Property Private mStringArray() As String Public Property StringArray() As String() Get Return mStringArray End Get Set(