我正在使用 VB 脚本代码在 HTA 文件中显示进度条。这工作正常,多次点击。问题是,直到发生任何用户交互(如消息框或任何错误窗口)之前,它都不会刷新。如果我在调用不同函数的单个子中调用它,它不会显示进度。
<Script Language="VBScript">
'------------for Progress bar --------------
Public w,x,y, MyTitle
w=100
x=0
y=100
MyTitle = " _ Progress"
'----------- w: bar width, x: done items, y: remaining items
Sub test
Progress(10)
callsubA()
Progress(10)
callsubB()
Progress(20)
callsubC()
Progress(10)
End Sub
Function Progress(step)
x=x+step
d = Round( x / (y/w) +1 ,0)
document.Title = FormatPercent(x/y, 0) & MyTitle
document.all.ProgBarText.innerText = x & "/" & y
document.all.ProgBarDone.innerText = String(d, "_")
If d<w Then
document.all.ProgBarToDo.innerText = String(w-d, "_") & "|"
Else
document.all.ProgBarToDo.innerText = "|"
End If
If x>=y Then
document.all.ProgBarToDo.innerText = ""
MsgBox "Migration Completed"
x=0
d = Round( x / (y/w) +1 ,0)
document.Title = "Completed"
document.all.ProgBarText.innerText = ""
document.all.ProgBarDone.innerText = ""
End If
End Function
</script>
我的 HTML 看起来像:
<span id="ProgBarText"></span><br>
<span id="ProgBarDone" style="background-color: #3399FF"></span>
<font color="#FFFFFF">
<span id="ProgBarToDo"style="background-color: #C0C0C0"></span>
</font>
如果我在每个子之后都给 msgbox,那么它工作正常....