- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have an old version of a VB6 program where I exchange data matrix and array from VB6 to CVF using the SafeArrayAccessData calls and similar. Everything worked properly.
Now I have already started in converting the VB6 application to VB2005, but before converting the Fortran DLLs, I decided to debug the VB2005 code with the same CVF DLLs.
The problem concerns the back data exchange from CVF to VB2005, because the Fortran code seems to not allocate the pointer pointing to the local matrix data (pointing to the same Input matrix) and then I cannot pass the elaborated data back to VB.
Considering the following example
arrayINPUT dimension (:) [passed in input]
loc_ARRAY dimension (:) [local matrix variable]
ptrINP integer
ptrARRAY pointer
POINTER(arrayINPUT, ptrINP)
POINTER(ptrARRAY, loc_ARRAY )
status=SafeArrayAccessData(arrayINPUT, ptrARRAY)
the problem seems to be located where it is asked to connect the arrayINPUT to the pointer ptrARRAY.
Any suggestions?
Thanks
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is the title of this thread correct? It seems to me that the problem is VB2005-CVF, right? I think that VB2005 (indeed 2002 and later) and VB6 are incompatible in the way they pass things, but I don't recall the details.
The samples I attached here include a SafeArray sample. Perhaps that will give you a clue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Why at the moment I cannot pass back the data matrix from CVF dll to VB05?
Why the pointer is not allocated?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So, just in order to give you a more detailed idea of the problem, I defined the following generic class:
Public Class clsMAT
Public Declare Function pigreek Lib "if_Mat.dll" () As Double
End class
and then the call is:
Imports clsMAT
Dim value as double
value=pigreek()
So, any idea? I also tried to debug the IVF dll, but I think the problems concerns the call dll, not directly inside the F90 code.
Regards and thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
During the debug of the Fortran function, the variable AngRAD and DEG have the following values:
ANGRAD -1.0803502417083776e+057 double (and not 3.1415!)
DEG -6.1899507523317673e+058 double (and not 180.0!)
that is very different from what was passed to the dll.
Any suggestions?
INTEL VISUAL FORTRAN
!DEC$ INTEGER : 4
!DEC$ REAL : 8
FUNCTION DEG(AngRAD)
!DEC$ ATTRIBUTES DLLEXPORT:: DEG
!DEC$ ATTRIBUTES ALIAS: 'DEG'::DEG
!DEC$ ATTRIBUTES STDCALL:: DEG
!DEC$ REFERENCE:: AngRAD
IMPLICIT NONE
REAL, INTENT(IN):: AngRAD
REAL:: DEG
!Execution section
DEG=AngRAD*180./3.1415
RETURN
END FUNCTION DEG
VISUAL BASIC 2005
(Function definition)
Class customMATH
Private Declare Function VBDEG Lib "ivfMATH.dll" _
Alias "DEG" (ByRef AngRAD As Double) As Double
Public Shared Function DEG(ByRef AngRAD As Double) As Double
changedir(PathDLL) 'change the directory to the directory where is located the ivfMATH.dll
DEG = VBDEG(AngRAD)
End Function
End Class
(call)
Dim value As Double
value = customMATH.DEG(CDbl(3.1415))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
!DEC$ ATTRIBUTES REFERENCE:: AngRAD
In addition, may I suggest not using !DEC$ INTEGER and !DEC$ REAL directives? Those are ugly hacks that, in my opinion, should be used only for making dusty decks work. If you want the precision setting centralized, a better option would be:
MODULE MyKinds
INTEGER, PARAMETER:: wp = 8
END MODULE MyKinds
FUNCTION Deg(...)
Use MyKinds
REAL(wp), INTENT(IN):: AngRad
...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm puzzled by your post but ..., in respect to vb6 and vb.net, the former, like fortran, stores arrays in column-major order and arrays are optionally 1-based, while the latter, like c/c++, stores arrays in row-major orderand they are always 0-based.
Ciao,
Gerry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Umm...! I dont know how VB.net is, but in VB6 arrays AREoptionally 0-based unless you declare them like MyArray (1 To n).
Sabalan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Let me see, the snippet
Option Explicit
Option Base 1 '0
Private Sub Form_Load()
Dim A(1) As Long
Debug.Print LBound(A); UBound(A)
End Sub
confirms the validity of the VB6 docs thatOption Base 0 is the defaultand Option Base 1 is optional. I believe that's what I said but in a more simpler way. With VB.NET all arrays are 0-basedno options about it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah, sorry! I mssed up "optional" and "default"! Yes, arrays in VB6 are 0-based by DEFAULT.
Sabalan

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page