Click here to Skip to main content
15,895,667 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: nature Pin
Dave Kreskowiak3-Mar-14 18:10
mveDave Kreskowiak3-Mar-14 18:10 
QuestionRe: nature Pin
Eddy Vluggen4-Mar-14 1:34
professionalEddy Vluggen4-Mar-14 1:34 
AnswerRe: nature Pin
Bernhard Hiller4-Mar-14 2:23
Bernhard Hiller4-Mar-14 2:23 
QuestionVB6 to VB.Net COM Interface Help Pin
sashaw22-Mar-14 9:37
sashaw22-Mar-14 9:37 
QuestionRe: VB6 to VB.Net COM Interface Help Pin
Richard Deeming3-Mar-14 0:36
mveRichard Deeming3-Mar-14 0:36 
AnswerRe: VB6 to VB.Net COM Interface Help Pin
sashaw23-Mar-14 4:16
sashaw23-Mar-14 4:16 
AnswerRe: VB6 to VB.Net COM Interface Help Pin
Richard Deeming3-Mar-14 7:17
mveRichard Deeming3-Mar-14 7:17 
GeneralRe: VB6 to VB.Net COM Interface Help <<< SOLVED >>> Pin
sashaw23-Mar-14 11:01
sashaw23-Mar-14 11:01 
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:

VB
<ComClass(clsValues.ClassId, clsValues.InterfaceId, clsValues.EventsId)> _
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 <MarshalAs(UnmanagedType.SafeArray, safearraysubtype:=VarEnum.VT_BSTR)> String()
        Return mStringArray.ToArray
    End Function
    Public Function StringArray(i As Short) As String
        Return mStringArray(i)
    End Function
    Public Sub SetStringArray(<MarshalAs(UnmanagedType.SafeArray, safearraysubtype:=VarEnum.VT_BSTR)> ByRef value As String())
        mStringArray = value
    End Sub
End Class


The final vb6 code looks like this:

VB
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.Description, vbCritical, "btnTest_Click"
    On Error Resume Next
End Sub


Thank you for the help - Mark this one as solved Smile | :)
QuestionPlease help me,.? Pin
M.Aprianto2-Mar-14 5:42
M.Aprianto2-Mar-14 5:42 
AnswerRe: Please help me,.? Pin
Eddy Vluggen2-Mar-14 7:44
professionalEddy Vluggen2-Mar-14 7:44 
Questionhow to make session timeout to automatically logout? Pin
charles entsuah28-Feb-14 10:31
charles entsuah28-Feb-14 10:31 
AnswerRe: how to make session timeout to automatically logout? Pin
ZurdoDev28-Feb-14 10:58
professionalZurdoDev28-Feb-14 10:58 
Questionupload pdf , save pdf in to a table, and read it from a datagrid on double click Pin
waner michaud28-Feb-14 9:07
waner michaud28-Feb-14 9:07 
AnswerRe: upload pdf , save pdf in to a table, and read it from a datagrid on double click Pin
Eddy Vluggen2-Mar-14 7:52
professionalEddy Vluggen2-Mar-14 7:52 
QuestionThreading.Thread.Sleep(5000) causing my splash screen to not show values. Help appreciated. Pin
ChristGuard26-Feb-14 9:46
ChristGuard26-Feb-14 9:46 
AnswerRe: Threading.Thread.Sleep(5000) causing my splash screen to not show values. Help appreciated. Pin
Dave Kreskowiak26-Feb-14 11:17
mveDave Kreskowiak26-Feb-14 11:17 
GeneralRe: Threading.Thread.Sleep(5000) causing my splash screen to not show values. Help appreciated. Pin
ChristGuard26-Feb-14 12:00
ChristGuard26-Feb-14 12:00 
GeneralRe: Threading.Thread.Sleep(5000) causing my splash screen to not show values. Help appreciated. Pin
Dave Kreskowiak26-Feb-14 16:17
mveDave Kreskowiak26-Feb-14 16:17 
Questionreading html data using the vb script Pin
Member 1062036024-Feb-14 17:32
Member 1062036024-Feb-14 17:32 
AnswerRe: reading html data using the vb script Pin
Dave Kreskowiak24-Feb-14 17:38
mveDave Kreskowiak24-Feb-14 17:38 
GeneralRe: reading html data using the vb script Pin
Member 1062036024-Feb-14 17:40
Member 1062036024-Feb-14 17:40 
GeneralRe: reading html data using the vb script Pin
Member 1062036024-Feb-14 17:43
Member 1062036024-Feb-14 17:43 
GeneralRe: reading html data using the vb script Pin
Dave Kreskowiak24-Feb-14 17:46
mveDave Kreskowiak24-Feb-14 17:46 
QuestionRunning VB6 programs in Windows 7 Pin
Wycombe24-Feb-14 12:00
Wycombe24-Feb-14 12:00 
AnswerRe: Running VB6 programs in Windows 7 Pin
Dave Kreskowiak24-Feb-14 14:49
mveDave Kreskowiak24-Feb-14 14:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.