Problem accessing string variable of C# structure in VB 6.0

SmartDeveloper 1 Reputation point
2021-07-20T03:26:08.133+00:00

I converted the C# DLL into a .tbl file in the VB6.0 program and referenced it (C# 32bit .NET 2.0 Framework)

If there is a string variable in a C# structure, a compile error occurs when the variable is declared with Dim in VB.

error Message : Variable uses an Automation type not supported in Visual Basic

How can I make it compatible with string variables in C# in VB6.0?

I'm not sure if I need to convert the string type to another type in C#, or if I need to declare the C# structure differently in the VB6.0 program, or if it is incompatible.

Please help me.

C# struct

public struct ApiSessionValidationStruct
{
public string user;
public string password;
public string client;
public bool isVip;
public bool isStation;
public string systemIdentifier;

    public ApiSessionValidationStruct(string user, string password, string client, bool isVip, bool isStation, string systemIdentifier)
    {
        this.user = user;
        this.password = password;
        this.client = client;
        this.isVip = isVip;
        this.isStation = isStation;
        this.systemIdentifier = systemIdentifier;
    }
}

VB 6.0 Source

Private Sub Command1_Click()

Dim mii As ItacMII
Dim abc As New ABCCC
Dim result As Integer
Dim errorString As String
Dim loginStruct As ApiSessionValidationStruct     'Error

Set mii = New ItacMII
result = mii.apiInit(errorString)
abc.test (result)
abc.test (errorString)

Text1.Text = mii.apiGetVersion()
abc.test (Text1.Text)

Set loginStruct = New ApiSessionValidationStruct     'Error
loginStruct.user = "48027510"
loginStruct.password = "1"
loginStruct.client = "01"
loginStruct.isVip = true
loginStruct.isStation = true
loginStruct.systemIdentifier =  "48027510"

result = mii.apiLogin(loginStruct, errorString)
abc.test (result)
abc.test (errorString)

End Sub

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
39,094 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.