可以来信索要;
[email protected]

解决方案 »

  1.   

    to:heyijpn(小何)
    我已给你发信,我急需,请速回,谢谢!
      

  2.   

    dim ss as long
       SS = TIMER
       DO
        doevents
        if timer - ss > 2
           EXIT LOOP
        end if 
       LOOP
      

  3.   

    to:ZRX_JYP(我想飞)
    你这个方法虽然可以,但CPU的使用率太高,我多次使用该延时,请问还有没有更好的方法?
    我想让它延时什么也不干,就想在Unix中的 Sleep 一样!
      

  4.   

    hehe,那你就用Windows的Sleep吧。
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    Private Declare Function SleepEx Lib "kernel32" (ByVal dwMilliseconds As Long, ByVal bAlertable As Long) As Long用:Sleep 2000
    或:Sleep 2000,false(不能被唤醒)
        Sleep 2000,True(可被唤醒)
      

  5.   

    用API函数sleep(2000),表示延时2秒。
      

  6.   

    一语唤醒梦中人。
    感谢sbnth(晓风残夜思春水)、Amoon(阿木) 。
    我一直是用死循环的方式,也感觉CPU占用太多,但是问题没有解决。
    再问一句:SLEEP(2000)后,需要唤醒吗?
      

  7.   

    Private WithEvents inet1 As Inet
    ....
    Private Sub Inet1_StateChanged(ByVal State As Integer)
        if State =icResponseCompleted then
    ...........End Sub
      

  8.   

    我在MSDN里找到的是:
       PauseTime = 1   ' 设置暂停时间。
       Start = Timer   ' 设置开始暂停的时刻。
       Do While Timer < Start + PauseTime
          DoEvents   ' 将控制让给其他程序。
       Loop
    但这个太费CPU了,我看了上面兄弟讲的sleep可,机子在那时候什么事都做不了,有什么好办法呢,我只是让和程序在运行完一个过程时,暂停一下
    有好办法告诉我
      

  9.   

    建一个timer,可以将循环内的代码放在timer事件里
      

  10.   

    呵呵、我也知道API的SLEEP,被别人先说掉了,但是好像SLEEP的时候是进程挂起,其他的什么都不能干了,让人觉得像死机,有什么解决方法吗?
      

  11.   

    谢谢各位的参与,下面我做一下总结:
      大家上面总共提了两中方法,其一,使用API函数中的 Sleep ;其二,使用一个循环。
    不过使用Sleep 我的其他进程什么也不干了,我之所以延时就是为了等待其他进程运行完后再继续运行,虽然这个方法不费CPU,却不能解决这个问题。
      使用循环,可以解决我的问题,但CPU的使用率在  90%±10%。我希望能一位高手来提供第三种解决方法!!!!!!!!
      

  12.   

    : lkz912(LKZ) :你可以试一下进程监控的方法,我之前的回复中提到过,我找出来再给你贴一遍吧。
    进程内执行shell的例子,只要把你要执行的命令当成DoExtComm函数的参数,vb会一直等到这个进程完了以后,才继续下一步的操作,希望对你有帮助。
    Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode 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 Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As LongPrivate Const CREATE_NEW_CONSOLE = &H10
    Private Const Process_query_infomation = &H400
    Private Const Still_Active = &H103'得到当前的操作系统信息
    Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
    Private Type OSVERSIONINFO
        dwOSVersionInfoSize As Long
        dwMajorVersion As Long
        dwMinorVersion As Long
        dwBuildNumber As Long
        dwPlatformId As Long
        szCSDVersion As String * 128
    End Type'得到当前window系统目录
    Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As LongPublic Function DoExtComm(sCommString As String)
        Dim nSysVer As Long
        Dim osInfo As OSVERSIONINFO
        Dim hProcess As Long
        Dim lExitCode As Long
        Dim sExecString As String
        Dim sCurDir As String
        Dim pidNotePad As Long
        Dim REt As Long
        Dim sCommPath As String
        'Set the structure size
        osInfo.dwOSVersionInfoSize = Len(osInfo)
        'Get the Windows version
        REt& = GetVersionEx(osInfo)
        'Chack for errors
        If REt& = 0 Then MsgBox "Error Getting Version Information"
        nSysVer = osInfo.dwPlatformId
        
        Dim Path As String, strSave As String
        'Create a buffer string
        strSave = String(200, Chr$(0))
        'Get the windows directory and
        Path = Left$(strSave, GetWindowsDirectory(strSave, Len(strSave)))
        If Mid(Path, Len(Path), 1) <> "\" Then Path = Path & "\"
        
    '    sWinDir = Environ("windir")
      sCommPath = Path
      
        If nSysVer = 1 Then                'windows98
            sExecString = sCommPath + "command.com  /c " + sCommString
        Else
            sExecString = sCommString
        End If
        
        pidNotePad = Shell(sExecString, vbHide)
        
        hProcess = OpenProcess(Process_query_infomation, True, pidNotePad)
        Do
            GetExitCodeProcess hProcess, lExitCode
            DoEvents
        Loop While lExitCode = Still_Active
        CloseHandle (pidNotePad)End Function
      

  13.   

    但是这个是用来执行shell命令的,我没有用过ftp,但我想你可以把程序改一下,这个部分:
    '    sWinDir = Environ("windir")
      sCommPath = Path
      
        If nSysVer = 1 Then                'windows98
            sExecString = sCommPath + "command.com  /c " + sCommString
        Else
            sExecString = sCommString
        End If
        
        pidNotePad = Shell(sExecString, vbHide)