0

Hey,

I have a VC++ DLL, which returns the sum of two long double values, passed as one dimensional array?

could anybody please tell the right syntax to pass array to this dll from vb.net

currently, my code snippet is as follows:
DllClass.vb

Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Runtime.InteropServices
Imports System.Diagnostics
Public Class DllClass
    Private Const dllfilename As String = "D:\vc++_prgs\dll_array\Debug\dll_array.dll"

    <DllImport(dllfilename, EntryPoint:="read", CharSet:=CharSet.Ansi)> _
    Public Shared Function read(ByVal c() As Double) As IntPtr
    End Function
End Class

Form1.vb

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       
        Dim arr(2) As Double
        arr(0) = Convert.ToDouble(TextBox1.Text)
        arr(1) = Convert.ToDouble(TextBox2.Text)
       
        Dim res As Double = DllClass.read(arr)
        TextBox3.Text = res.ToString
    End Sub
End Class

Thanks in anticipation

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by __avd
0

>I have a VC++ DLL, which returns the sum of two long double values

<DllImport(filename, EntryPoint:="read")> Public Function read(ByVal d() As Double) As Double
    End Function
Dim dbl as Double = read(New Double() {22, 33})
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.