该怎么办呢难哦 发表于 2003-10-22 19:47:00

这个话题该在这里吧!用API函数调用FORTRAN程序在VB里输入和显示数据

这是FORTRAN程序:
program sort
      dimension arr(10)
      integer n
      nupper=10
      open(1,file='e:\beforesort.dat',status='old')
      do 10 n=1,nupper
      read(1,*) arr(n)
10continue
      open(2,file='e:\aftersort.dat')
      do 40 n=1,nupper
      write(2,100)'第',n,'数',arr(n)
      write(*,100)'第',n,'个数',arr(n)
   40 continue
100 format(1x,a5,i2,a5,1x,f8.3)
      close(1)
      close(2)
      end

在VB里用API函数调用FORTRAN
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long

Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long

Private Const infinite = -1&
Private Const synchroniz = &H100000

Private Sub Command1_Click()
Dim itask As Long, ret As Long, phandle As Long

filename1 = "e:\beforesort.dat"
filename2 = "e:\aftersort.dat"
Open filename1 For Output As #1
For i = 0 To 9
   Print #1, Val(Text1(i).Text)
Next
Close #1
itask = Shell("e:\sort.exe", vbHide)
phandle = OpenProcess(synchronize, False, itask)
ret = WaitForSingleObject(phandle, infinite)
ret = CloseHandle(phandle)
RichTextBox1.LoadFile filename2, rtfText
End Sub

程序执行时出现死机现象,怎么回事?

mccad 发表于 2003-10-22 20:08:00

你已经在FORTRAN中生成了文本文件,其实在VB中显示文本文件不用那么复杂吧

该怎么办呢难哦 发表于 2003-10-22 20:55:00

问题已经解决!谢谢明总
页: [1]
查看完整版本: 这个话题该在这里吧!用API函数调用FORTRAN程序在VB里输入和显示数据