- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Passing Array of Characters
I have been trying to pass a character array from FORTRAN DLL to VBA Excel but I havent had any luck
Is there an easier way to do it than the way I have below?
subroutine testme1(A1,A2,A3,A4)
!dec$ attributes dllexport, stdcall, reference, alias : 'testme1' :: testme1
use testme10
implicit none
character*255 :: A1,A2,A3,A4
!character*255, dimension(4) :: char256
!char255(1) = A1
!char255(2) = A2
!char255(3) = A3
!char255(4) = A4
call testme
!A1 = char255(1)
!A2 = char255(2)
!A3 = char255(3)
!A4 = char255(4)
endsubroutine testme1
module testme10
implicit none
character*255, dimension(4) :: char255
data char255(:) / 'absd','dfsdf','sdsdfds','ssddtg'/
CONTAINS
subroutine testme
save
char255(1) ='abscde'
char255(2) ='fghijklm'
char255(3) ='nopqr'
char255(4) ='stuvwxyz'
endsubroutine testme
endmodule testme10
Public Declare Sub testme1 Lib "Z:\\Visual Studio 2008\\Projects\\Dll8\\Dll8\\Release\\Dll8.dll" (ByVal A1 As String, ByVal A2 As String, ByVal A3 As String, ByVal A4 As String, A20 As Long, A21 As Long, A22 As Long, A23 As Long)
Sub testme()
Dim char255(4) As String * 255
'integer4(1) = 255&;
'integer4(2) = 255&
'integer4(3) = 255&
'integer4(4) = 255&
char255(1) = "abcde"
char255(2) = "fghijkl"
char255(3) = "monoidj"
char255(4) = "dflivndsfv"
Call testme1(char255(1), char255(2), char255(3), char255(4), 255&, 255&, 255&, 255&)
'Call testme1(char255(1))
End Sub
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
FORTRAN:
subroutine fsubstringarray(c)
!dec$ attributes dllexport, stdcall, reference, alias : 'fsubstringarray' :: fsubstringarray
character*255 c(4)
c(1) = c(1)(1:index(c(1),' ') - 1)//'element1'
c(2) = c(2)(1:index(c(2),' ') - 1)//'element2'
c(3) = c(3)(1:index(c(3),' ') - 1)//'element3'
c(4) = c(4)(1:index(c(4),' ') - 1)//'element4'
end
VBA:
Option Explicit
Type stringarray
s(1 To 4) As String * 255
End Type
Dim sa As stringarray
Public Declare Sub fsubstringarray Lib "z:\visual studio 2008\projects\dll8\dll8\release\dll8.dll" (ByRef sa As stringarray, ByVal clen As Long)
Sub teststringarray()
sa.s(1) = "dskjbksad"
sa.s(2) = "fvdfhfthg"
sa.s(3) = "fgn"
sa.s(4) = "jkljgklg"
Call fsubstringarray(sa, 255&)
End Sub
![](/skins/images/895D6060305DF45A57FACF854B5A8CD1/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page