×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Problems calling a Visual Fortran DLL from VB6.0

Problems calling a Visual Fortran DLL from VB6.0

Problems calling a Visual Fortran DLL from VB6.0

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close