Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a Compaq Visual Fortran Dll From VB6.0

Status
Not open for further replies.

Imageek

Programmer
May 24, 2001
5
0
0
GB
I am having troble passing a varying size array from VB to VF where in the DLL call statement I pass across the first value in the array ( e.g. Array(1)) and the dimension (e.g. 10) and when I try to use the dimension in VF to dimensionalise the array it doesn’t use the value.

This is a very simple version of the problem (based on the Fcall example on the Compaq homepage)

Vb code

Module

Declare Sub DLL_ROUT Lib "H:\COMA32\FCALL\Debug\Fcall.dll" (ByRef INT_ARG As Long, ByVal STR_IN As String, ByVal STR_IN_LEN As Long, ByVal STR_OUT As String, ByVal STR_OUT_LEN As Long, ByRef intTod As Integer, ByRef tod As Integer)


Form

Private Sub Command1_Click()
Static STR_IN As String * 10, STR_OUT As String * 20, INT_ARG As LogModeConstants
Dim IntArrayList(1 To 10) As Integer
Dim i As Integer
Dim intDim As Integer

intDim = 10
For i = 1 To 10
IntArrayList(i) = 10 * i
Next
INT_ARG = 123
STR_IN = "Testing..."

‘Pass lengths of string arguments

Call DLL_ROUT(INT_ARG, STR_IN, Len(STR_IN), STR_OUT, Len(STR_OUT), intDim, IntArrayList(1))

MsgBox (STR_OUT)
MsgBox (IntArrayList(6))
End Sub


Visual fortan 6.0


SUBROUTINE DLL_ROUT (INT_ARG, STR_IN, STR_OUT, intDim, IntArrayList)
IMPLICIT NONE

! Specify that DLL_ROUT is exported to a DLL
! and that the external name is 'DLL_ROUT'

!DEC$ ATTRIBUTES DLLEXPORT :: DLL_ROUT
!DEC$ ATTRIBUTES ALIAS:'DLL_ROUT' :: DLL_ROUT

INTEGER(2) INT_ARG
INTEGER(2) intDim
CHARACTER*(*) STR_IN, STR_OUT
INTEGER(2) IntArrayList(intDim)
INTEGER ioerror
! This routine converts INT_ARG to a decimal string.
! appends the string value to STR_IN and stores it
! in STR_OUT.
! Note that there are implicit length arguments
! following the addresses of each CHARACTER argument.

CHARACTER*5 INT_STR
WRITE (INT_STR,'(I5.5)')INT_ARG
STR_OUT = STR_IN // INT_STR

IntArrayList(6)=10000

RETURN

END

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top