- 积分
- 1719
- 明经币
- 个
- 注册时间
- 2002-11-4
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
这是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
程序执行时出现死机现象,怎么回事? |
|