Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
S

sashaw2

@sashaw2
About
Posts
7
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Planetary orbit problems again
    S sashaw2

    Take a look at this video https://www.youtube.com/watch?v=yp5kQtQwPNQ&feature=youtu.be

    The Lounge question

  • Is it possible to pass a collection by reference from vb6 to vb.net?
    S sashaw2

    Thanks for your help. I was able to get it working as you described.

    Visual Basic csharp question announcement

  • Is it possible to pass a collection by reference from vb6 to vb.net?
    S sashaw2

    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.

    Visual Basic csharp question announcement

  • Is it possible to pass a collection by reference from vb6 to vb.net?
    S sashaw2

    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).

    Visual Basic csharp question announcement

  • VB6 to VB.Net COM Interface Help
    S sashaw2

    I 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

    Visual Basic help csharp com windows-admin

  • VB6 to VB.Net COM Interface Help
    S sashaw2

    Thank you for the reply It is a typo but this is where the error occurs, see error message at top of message after correction.

    Visual Basic help csharp com windows-admin

  • VB6 to VB.Net COM Interface Help
    S sashaw2

    Why 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(
    
    Visual Basic help csharp com windows-admin
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups