[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 303
  • Last Modified:

declaring dll function...

I have dll(in fortran) function with an multidimension array argument type. How can i declare this funtion in my VB code?


Thanx
Mário Guedes
0
mguedes
Asked:
mguedes
1 Solution
 
twardCommented:
I believe this would work for Fortran, although only testing with a C DLL:

#If Win32 Then

    Private Declare Function ProcessArray Lib "vb4dll32.dll"(a() As _
        String) As Variant
    Private Declare Function CopyArray Lib "vb4dll32.dll" (a() As _
        String) As Variant

#Else

    Private Declare Function ProcessArray Lib "vb4dll16.dll"(a() As _
        String) As Variant
    Private Declare Function CopyArray Lib "vb4dll16.dll" (a() As _
        String) As Variant

#End If


Private Sub ArrayTest()

    Dim a(4, 5, 6) As String
    Dim v1 As Variant

    a(0, 1, 2) = "Hello!"

    Print VarType(v1)
    v1 = ProcessArray(a())
    Print VarType(v1)

    MsgBox v1(0, 1, 2), vbInformation, "Element Value of Array _
           Returned In Variant - 1"
    MsgBox a(0, 1, 2), vbInformation, "Modified Element Value of _
           Passed-in Array - 1"

    v2 = CopyArray(a())
    Print VarType(v2)

    MsgBox v2(0, 1, 2), vbInformation, "Element Value of Array _
           Returned In Variant - 2"
    MsgBox a(0, 1, 2), vbInformation, "Modified Element Value of _
           Passed-in Array - 2 "

End Sub

0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now