Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help with HTML Progress Bar

Status
Not open for further replies.

cluM09

Technical User
May 15, 2004
127
US
Hello,

I got a sample html progress bar script from the internet that works quite well. The code is listed below.

However, I don't want the bar to move forward and then backward while it is waiting. I just want to bar to move forward and when it reaches the end, I want it start at the beginning and move forward repeatedly until the wait time is over. In other words, I only want to bar to forward, and when it reaches the end, I want it to start at the beginning and move forward again and again until the wait time is over.

Is it possible to do just have the progress bar move forward as I described above?

******************************************************
Option Explicit

Const conBarSpeed=150
Const conForcedTimeOut=10000

Dim objIE
Dim objProgressBar
Dim objTextLine1
Dim objTextLine2
Dim objQuitFlag

Sample

Public Sub Sample()
Dim intCount
StartIE "Progress"
SetLine1 "Please wait while copying files. . ."
For intCount = 1 To 50000
If IsQuit()=True Then
Exit For
End If
Next
CloseIE
End Sub

Private Sub StartIE(strTitel)
Dim objDocument, objWshShell

Set objIE = CreateObject("InternetExplorer.Application")

objIE.height = 150
objIE.width = 395
objIE.menubar = False
objIE.toolbar = false
objIE.statusbar = false
objIE.addressbar = false
objIE.resizable = False
objIE.navigate ("about:blank")

' Wait till ie is loaded
While (objIE.busy)
wend

set objDocument = objIE.document

' setup the dialog box
WriteHtmlToDialog objDocument, strTitel

' With ie/html loaded, define assorted objects...
set objTextLine1 = objIE.document.all("txtMilestone")
Set objProgressBar = objIE.document.all("pbText")
set objQuitFlag = objIE.document.Secret.pubFlag

objTextLine1.innerTEXT = ""

'objIE.document.body.innerHTML = "Building Document..." + "<br>load time= " + n
objIE.visible = True

' set focus to ie.
Set objWSHShell = WScript.CreateObject("WScript.Shell")
objWshShell.AppActivate("Windows Internet Explorer")

End Sub

' Close IE.
Private Function CloseIE()
On Error Resume Next
objIE.quit
End Function

' Set Text Line in the Progress Bar Dialog Box
Private sub SetLine1(sNewText)
On Error Resume Next
objTextLine1.innerTEXT = sNewText
End Sub

Private function IsQuit()
On Error Resume Next
IsQuit=True
If objQuitFlag.Value<>"quit" Then
IsQuit=False
End If
End function

' Set HTML Text for the IE Dialog box
Private Sub WriteHtmlToDialog(objDocument, strTitel)

objDocument.Open

objDocument.Writeln "<title>" & strTitel & "</title> "

objDocument.Writeln "<style>"
objDocument.Writeln " BODY {background: Silver} BODY { overflow:hidden }"
objDocument.Writeln " P.txtStyle {color: Navy; font-family: Verdana; " _
& " font-size: 10pt; font-weight: bold; margin-left: 10px } "

objDocument.Writeln " input.pbStyle {color: Navy; font-family: Wingdings; " _
& " font-size: 10pt; background: Silver; height: 20px; " _
& " width: 340px } "
objDocument.Writeln "</style>"

objDocument.Writeln "<div id=""objProgress"" class=""Outer""></div>"

' write out text lines...
objDocument.Writeln "<P id=txtMilestone class='txtStyle' style='margin-left: 10px'> </P>"
objDocument.Writeln "<CENTER>"

' write progbar
objDocument.Writeln "<input type='text' id='pbText' class='pbStyle' value='' >"
objDocument.Writeln "<br><br>" ' space down a little
objDocument.Writeln "</CENTER>"

' write hidden object...
objDocument.Writeln "<form name='secret' >" _
& " <input type='hidden' name='pubFlag' value='run' >" _
& "</form>"

objDocument.Writeln "<SCRIPT LANGUAGE='VBScript' >"

' progress bar
objDocument.Writeln "Function PctComplete(nPct)"
objDocument.Writeln " pbText.Value = String(nPct,"" "") & String(4,""n"")"
objDocument.Writeln "End Function"

' calc progress bar and direction
objDocument.Writeln "Sub UpdateProgress()"
objDocument.Writeln "Dim intStep"
objDocument.Writeln "Dim intDirection"

objDocument.Writeln "If (IsNull(objProgress.getAttribute(""Step"")) = True) Then"
objDocument.Writeln "intStep = 0"
objDocument.Writeln "Else"
objDocument.Writeln "intStep = objProgress.Step"
objDocument.Writeln "End If"

objDocument.Writeln "If (IsNull(objProgress.GetAttribute(""Direction""))=True) Then"
objDocument.Writeln "intDirection = 0"
objDocument.Writeln "Else"
objDocument.Writeln "intDirection = objProgress.Direction"
objDocument.Writeln "End If"

objDocument.Writeln "If intDirection = 0 then"
objDocument.Writeln "intStep = intStep + 1"
objDocument.Writeln "Else"
objDocument.Writeln "intStep = intStep - 1"
objDocument.Writeln "End If"

objDocument.Writeln "Call PctComplete(intStep)"

objDocument.Writeln "If intStep >= 23 Then"
objDocument.Writeln " intDirection = 1"
objDocument.Writeln "End If"
objDocument.Writeln "If intStep <=0 Then"
objDocument.Writeln " intDirection = 0"
objDocument.Writeln "End If"

objDocument.Writeln "objProgress.SetAttribute ""Step"", intStep"
objDocument.Writeln "objProgress.SetAttribute ""Direction"", intDirection"

objDocument.Writeln "Window.setTimeout GetRef(""UpdateProgress""), " & conBarSpeed
objDocument.Writeln "End Sub"

' timeout function
objDocument.Writeln "Sub DialogHardTimeout()"
objDocument.Writeln "SetReturnFlag(""quit"")"
objDocument.Writeln "End sub"

objDocument.Writeln "Sub Window_OnLoad()"
objDocument.Writeln "theleft = (screen.availWidth - document.body.clientWidth) / 2"
objDocument.Writeln "thetop = (screen.availHeight - document.body.clientHeight) / 2"
objDocument.Writeln "window.moveTo theleft,thetop"
objDocument.Writeln "Window.setTimeout GetRef(""UpdateProgress""), " & conBarSpeed
objDocument.Writeln "Window.setTimeout GetRef(""DialogHardTimeout""), " & conForcedTimeOut
objDocument.Writeln "End Sub"

objDocument.Writeln "</SCRIPT>"

objDocument.Close

End Sub

**********************************************************

Thanks.
 
There is only one bit of HTML in that code

Code:
</SCRIPT>

Oh, there's a <br> too!
:)

The rest if VBScript. Might I suggest you try the VB forum? They'll probably be of more help than I am being :)

--
Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.


 
Or even better try forum329

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top