进度显示的问题,很着急

zhangtao1st 2003-10-18 09:00:19
各位好,我在遇到的问题是这样的,我于程序来备份数据库,但是在备分的过程中
电脑就象死机了一样,点击无任何反映,这样对用户来说难以忍受
我的意思是
 在备份的过程中要给用户一些动太的提示,如进度条等,但是用进度条需要知道最大值,这个对于这个程序来说不好确定。
 我也尝试用定时器控件,但是也不会正确的响应。
不知道哪个高手能帮我这个忙,只要能让用户感觉到机器正在运行程序,并没有死机
从而耐心等代就可以了。
 具体方法不限。
...全文
48 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
蒋宏伟 2003-10-20
  • 打赏
  • 举报
回复
建立一个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事件后压缩结束
kmzs 2003-10-19
  • 打赏
  • 举报
回复
用VB?异想天开??
蒋宏伟 2003-10-19
  • 打赏
  • 举报
回复
你是用dao或ado吗?那么上面的方法都不行的.只能把它做到一个dll里面去.
flc 2003-10-19
  • 打赏
  • 举报
回复
xuexi
rainstormmaster 2003-10-18
  • 打赏
  • 举报
回复
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 Sub

Private Sub Form_Load()
backing = False
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
'其他事件类似,即首先判断backing的值,如果backing为false,才继续执行
If backing Then
MsgBox "不要心急"
Cancel = 1
End If

End Sub
goodname008 2003-10-18
  • 打赏
  • 举报
回复
' 抛砖引玉

Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Sub Form_Load()
Timer1.Interval = 1
End Sub

Private 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
goodname008 2003-10-18
  • 打赏
  • 举报
回复
用过X-Scan吗?可以做成X-Scan左下角那样的进度条。

其实就是安装XP时那种左右来回走的进度条,很好看。

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧