明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1802|回复: 2

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

[复制链接]
发表于 2003-10-22 19:47:00 | 显示全部楼层 |阅读模式
这是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)
  10  continue
      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

程序执行时出现死机现象,怎么回事?
发表于 2003-10-22 20:08:00 | 显示全部楼层
你已经在FORTRAN中生成了文本文件,其实在VB中显示文本文件不用那么复杂吧
 楼主| 发表于 2003-10-22 20:55:00 | 显示全部楼层
问题已经解决!谢谢明总
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-28 13:38 , Processed in 0.177609 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表