VB调用FORTRAN DLL问题!
我的程序基本功能是:从VB窗体中的dialog打开和保存文件按钮得到输入和输出文件名,然后调用FORTRAN程序,对输入文件中的数据进行处理之后将这些数据再写入输出文件中...
我的程序基本功能是:从VB窗体中的dialog打开和保存文件按钮得到输入和输出文件名,然后调用FORTRAN 程序,对输入文件中的数据进行处理之后将这些数据再写入输出文件中(FORTRAN中进行)。参数就是这两个输入输出文件名。但是调用老出问题,请高手帮我看看程序代码,到底哪里写的有问题。是不是接口定义的问题啊!谢谢啦!
我的FORTRAN代码为:
SUBROUTINE TRANSFER1(FILE1,FILE2)
!ms$ ATTRIBUTES DLLEXPORT::TRANSFER1
!ms$ ATTRIBUTES ALIAS:'_TRANSFER1@2'::TRANSFER1
REAL T(50000),A(50000),T1(50000),A1(50000)
INTEGER SUM,I,J,N,N1
CHARACTER*(*) FILE1
CHARACTER*(*) FILE2
N1=42
OPEN(10,FILE=FILE1,STATUS='UNKNOWN')
DO I=1,7
READ(10,*)
END DO
SUM=0
DO WHILE(.NOT.EOF(10))
READ(10,*)
SUM=SUM+1
END DO
REWIND(10)
DO I=1,7
READ(10,*)
END DO
DO I=1,SUM
READ(10,*) T(I),A(I)
END DO
CLOSE(10)
OPEN(11,FILE=FILE2,STATUS='UNKNOWN')
DO J=1,INT(SUM/5/N1/N)+1
DO I=1,N1
WRITE(11,100) T((J-1)*N1*5+I),A((J-1)*N1*5+I),T((J-1)*N1*5+I+N1),A((J-1)*N1*5+I+N1),T((J-1)*N1*5+I+N1*2),A((J-1)*N1*5+I+N1*2),T((J-1)*N1*5+I+N1*3),A((J-1)*N1*5+I+N1*3),T((J-1)*N1*5+I+N1*4),A((J-1)*N1*5+I+N1*4)
END DO
END DO
100 FORMAT(<10>(F10.2,2X))
CLOSE(11)
END PROGRAN
我的VB调用代码为:
Private Declare Sub TRANSFER1 Lib "D:\1VB\Visual.Basic.6.0.with.SP6\VB98\1我的练习\5列42行隔点输出\隔点输出5列42行2222\Debug\隔点输出5列42行.dll" Alias "_TRANSFER1@2" (ByVal InFile1 As String, ByVal InFile1Len As Long, ByVal InFile2 As String, ByVal InFile2Len As Long)
Dim InFile1 As String, InFile2 As String
Private Sub Command1_Click()
CommonDialog1.InitDir = "D:\1VB\Visual.Basic.6.0.with.SP6\VB98\1我的练习\5列42行隔点输出\隔点输出5列42行2222" '打开文件的初始路径
CommonDialog1.ShowOpen
Text1 = CommonDialog1.FileName
End Sub
Private Sub Command2_Click()
Static Flg As Boolean
CommonDialog1.InitDir = "D:\1VB\Visual.Basic.6.0.with.SP6\VB98\1我的练习\5列42行隔点输出\隔点输出5列42行2222"
CommonDialog1.ShowSave
If Dir(CommonDialog1.FileName) <> "" And Not Flg Then
If MsgBox("文件已存在,要覆盖吗?", vbYesNo, "注意") = vbYes Then
Text2 = CommonDialog1.FileName
Exit Sub
End If
Text2 = CommonDialog1.FileName
End If
End Sub
Private Sub Command3_Click()
On Error Resume Next
InFile1 = Text1
InFile2 = Text2
Call TRANSFER1(InFile1, Len(InFile1), InFile2, Len(InFile2))
MsgBox "转换成功"
End Sub
代码完毕!
我感觉是我的参数传递有问题。请帮我看看。 展开
我的FORTRAN代码为:
SUBROUTINE TRANSFER1(FILE1,FILE2)
!ms$ ATTRIBUTES DLLEXPORT::TRANSFER1
!ms$ ATTRIBUTES ALIAS:'_TRANSFER1@2'::TRANSFER1
REAL T(50000),A(50000),T1(50000),A1(50000)
INTEGER SUM,I,J,N,N1
CHARACTER*(*) FILE1
CHARACTER*(*) FILE2
N1=42
OPEN(10,FILE=FILE1,STATUS='UNKNOWN')
DO I=1,7
READ(10,*)
END DO
SUM=0
DO WHILE(.NOT.EOF(10))
READ(10,*)
SUM=SUM+1
END DO
REWIND(10)
DO I=1,7
READ(10,*)
END DO
DO I=1,SUM
READ(10,*) T(I),A(I)
END DO
CLOSE(10)
OPEN(11,FILE=FILE2,STATUS='UNKNOWN')
DO J=1,INT(SUM/5/N1/N)+1
DO I=1,N1
WRITE(11,100) T((J-1)*N1*5+I),A((J-1)*N1*5+I),T((J-1)*N1*5+I+N1),A((J-1)*N1*5+I+N1),T((J-1)*N1*5+I+N1*2),A((J-1)*N1*5+I+N1*2),T((J-1)*N1*5+I+N1*3),A((J-1)*N1*5+I+N1*3),T((J-1)*N1*5+I+N1*4),A((J-1)*N1*5+I+N1*4)
END DO
END DO
100 FORMAT(<10>(F10.2,2X))
CLOSE(11)
END PROGRAN
我的VB调用代码为:
Private Declare Sub TRANSFER1 Lib "D:\1VB\Visual.Basic.6.0.with.SP6\VB98\1我的练习\5列42行隔点输出\隔点输出5列42行2222\Debug\隔点输出5列42行.dll" Alias "_TRANSFER1@2" (ByVal InFile1 As String, ByVal InFile1Len As Long, ByVal InFile2 As String, ByVal InFile2Len As Long)
Dim InFile1 As String, InFile2 As String
Private Sub Command1_Click()
CommonDialog1.InitDir = "D:\1VB\Visual.Basic.6.0.with.SP6\VB98\1我的练习\5列42行隔点输出\隔点输出5列42行2222" '打开文件的初始路径
CommonDialog1.ShowOpen
Text1 = CommonDialog1.FileName
End Sub
Private Sub Command2_Click()
Static Flg As Boolean
CommonDialog1.InitDir = "D:\1VB\Visual.Basic.6.0.with.SP6\VB98\1我的练习\5列42行隔点输出\隔点输出5列42行2222"
CommonDialog1.ShowSave
If Dir(CommonDialog1.FileName) <> "" And Not Flg Then
If MsgBox("文件已存在,要覆盖吗?", vbYesNo, "注意") = vbYes Then
Text2 = CommonDialog1.FileName
Exit Sub
End If
Text2 = CommonDialog1.FileName
End If
End Sub
Private Sub Command3_Click()
On Error Resume Next
InFile1 = Text1
InFile2 = Text2
Call TRANSFER1(InFile1, Len(InFile1), InFile2, Len(InFile2))
MsgBox "转换成功"
End Sub
代码完毕!
我感觉是我的参数传递有问题。请帮我看看。 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询