各位好,我在遇到的问题是这样的,我于程序来备份数据库,但是在备分的过程中
电脑就象死机了一样,点击无任何反映,这样对用户来说难以忍受
我的意思是
 在备份的过程中要给用户一些动太的提示,如进度条等,但是用进度条需要知道最大值,这个对于这个程序来说不好确定。
 我也尝试用定时器控件,但是也不会正确的响应。
不知道哪个高手能帮我这个忙,只要能让用户感觉到机器正在运行程序,并没有死机
从而耐心等代就可以了。
 具体方法不限。

解决方案 »

  1.   

    用过X-Scan吗?可以做成X-Scan左下角那样的进度条。其实就是安装XP时那种左右来回走的进度条,很好看。
      

  2.   

    ' 抛砖引玉Option Explicit
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)Private Sub Form_Load()
    Timer1.Interval = 1
    End SubPrivate Sub Timer1_Timer()
    Static x As Long
    Static direction As Boolean
    If direction = False Then
        Picture1.ForeColor = RGB((255 / Picture1.Width) * x, 0, 255)
        x = x + 5
        Picture1.Line (x, 0)-(x, Picture1.Height)
        If x >= Picture1.Width Then direction = True
    Else
        Picture1.ForeColor = RGB((255 / Picture1.Width) * x, 255, 0)
        x = x - 5
        Picture1.Line (x, 0)-(x, Picture1.Height)
        If x <= 0 Then direction = False
    End If
    End Sub
      

  3.   

    Dim backing As Boolean
    Private Sub Command1_Click()
        Dim i As Long
        backing = True '在长时间操作之前,指定backing的值为true
        
        '将doevents语句加入到你的备份语句合适位置,这里我用一个长循环消耗系统时间
        For i = 1 To 60000
            DoEvents
            Debug.Print i
        Next
        '备份结束后,恢复backing的值为false
        backing = False
    End SubPrivate Sub Form_Load()
        backing = False
    End SubPrivate Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    '其他事件类似,即首先判断backing的值,如果backing为false,才继续执行
        If backing Then
            MsgBox "不要心急"
            Cancel = 1
        End IfEnd Sub
      

  4.   

    你是用dao或ado吗?那么上面的方法都不行的.只能把它做到一个dll里面去.
      

  5.   

    建立一个ActiveX Exe,加入一个类模块clsCompDB
    private Timerid as long
    public Event CompactOK()
    public sub CompactDB()   
        set Loder =me
        Call SetTimer(0, Timerid, 10, AddressOf TimerProc)
    end sub
    friend sub CompOK()
        raiseevent CompactOK
    end sub
    加入一个模块
    public Loder as clsCompDB
    public Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
    public Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
    Public Function TimerProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idEvent As Long, ByVal dwTime As Long) As Long
        killtimer 0,timerid
        '加入压缩代码
        'call loder.CopmOk
        set loder=nothing
    end sub
    再你的程序中引用这个activexexe,withevents创建一个clsCompDB对象,调用CompactDB方法,接收到CompOK事件后压缩结束