- 积分
- 1719
- 明经币
- 个
- 注册时间
- 2002-11-4
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2003-10-22 16:45:00
|
显示全部楼层
本帖最后由 作者 于 2003-10-22 20:53:08 编辑
这是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
close(1)
open(2,file='e:aftersort.dat',status='new')
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(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 = "a:\beforesort.dat"
filename2 = "a:\aftersort.dat"
Open filename1 For Output As #1
For i = 0 To 9
Print #1, Val(Text1(i).Text)
Next
Close #1
itask = Shell("a:\sort.exe", vbHide)
phandle = OpenProcess(synchronize, False, itask)
ret = WaitForSingleObject(phandle, infinite)
ret = CloseHandle(phandle)
RichTextBox1.LoadFile filename2, rtfText
End Sub
问题解决!
可以通过API在VB或VBA里实现。 |
|