首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

请教能不能在一个子程序结束后调用另一个子程序

2012-03-01 
请问能不能在一个子程序结束后调用另一个子程序?比如在这个子程序中传递另一个子程序的地址,等这个子程序

请问能不能在一个子程序结束后调用另一个子程序?
比如在这个子程序中传递另一个子程序的地址,等这个子程序完成后系统再调用另一个子程序。
谢谢

[解决办法]
Option Explicit
\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '
\ ' Distribution: isumh coded.
\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '\ '
Private Const WAIT_INFINITE = -1&
Private Const SYNCHRONIZE = &H100000

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

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 Sub Command1_Click()

Dim hProcess As Long
Dim taskId As Long
Dim cmdline As String

cmdline = "notepad.exe "
taskId = Shell(cmdline, vbNormalFocus)

hProcess = OpenProcess(SYNCHRONIZE, True, taskId)
Call WaitForSingleObject(hProcess, WAIT_INFINITE)
CloseHandle hProcess

MsgBox "调用的程序结束. "

End Sub


[解决办法]
可以,shell 后加个带时间延时的BAT文件,下一条语句直接END就行了
[解决办法]
前些天就讨论过这个问题了。
http://community.csdn.net/Expert/topic/5665/5665808.xml?temp=.5346033

热点排行