<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>North Atlanta Web Design &#187; Progress Bar</title>
	<atom:link href="https://www.northatlantawebdesign.com/index.php/tag/progress-bar/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.northatlantawebdesign.com</link>
	<description>Programming Examples, Samples, and Tutorials</description>
	<lastBuildDate>Mon, 15 Aug 2011 20:18:35 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=3.7.41</generator>
	<item>
		<title>HTA Progress Bar using VBScript and JavaScript</title>
		<link>https://www.northatlantawebdesign.com/index.php/2009/07/17/hta-progress-bar-using-vbscript-and-javascript/</link>
		<comments>https://www.northatlantawebdesign.com/index.php/2009/07/17/hta-progress-bar-using-vbscript-and-javascript/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 17:53:30 +0000</pubDate>
		<dc:creator><![CDATA[Jeff Gibeau]]></dc:creator>
				<category><![CDATA[HTML Applications]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[HTA]]></category>
		<category><![CDATA[Progress Bar]]></category>
		<category><![CDATA[Progressbar]]></category>
		<category><![CDATA[VBScript Front End]]></category>
		<category><![CDATA[VBScript GUI]]></category>

		<guid isPermaLink="false">http://www.northatlantawebdesign.com/?p=88</guid>
		<description><![CDATA[I was informed after my last post that using HTA (HTML Applications) to display a progress bar in VBScript is much more efficient than using InternetExplorer.Application within a VBScript. Having never used HTA before, I immediately set out to learn a bit and see what I could come up with. My initial thoughts are mixed, [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>I was informed after my <a href="http://www.northatlantawebdesign.com/index.php/2009/07/16/simple-vbscript-progress-bar/">last post</a> that using <a type="amzn">HTA</a> (HTML Applications) to display a progress bar in <a type="amzn">VBScript</a> is much more efficient than using InternetExplorer.Application within a VBScript.  Having never used HTA before, I immediately set out to learn a bit and see what I could come up with.</p>
<p>My initial thoughts are mixed, as <strong>you can not run and interact with an HTA from a VBScript file</strong>.  This requires you to wrap your VBScript code in whatever HTML Application you are writing.  This greatly limits re-usability, enough so that the increase in performance may not warrant using an HTA for a progress bar in most cases.<br />
<span id="more-88"></span><br />
I would like to note that this is a first draft of this script, and I may update it in the future, if I deem HTML Applications the way to go.  As for now, I am not convinced.</p>
<pre class="brush: vb; title: ; notranslate">
&lt;html&gt;
&lt;head&gt;
	&lt;title&gt;HTA Progress Bar&lt;/title&gt;
&lt;script language=&quot;vbscript&quot;&gt;
'This script resizes and moves the window to the center of the screen.
'The placement of this code above the HTA definition, moves the window
'before the script is visible. 
height = screen.height
width = screen.width
moveto width/2 - 335/2,height/2 - 200/2
resizeto 335,200
&lt;/script&gt;
	&lt;HTA:APPLICATION ID=&quot;oMyApp&quot;
		APPLICATIONNAME=&quot;monster&quot;
		SINGLEINSTANCE=&quot;yes&quot;
		BORDER=&quot;thin&quot;
		MAXIMIZEBUTTON=&quot;no&quot;
&gt;

&lt;script language=&quot;VBScript&quot; type=&quot;text/vbscript&quot;&gt;
'This is where your VBScript logic should go.
' Call OpenProgressBar to open the progressbar
' Call UpdateLog to update the logging window
' Call UpdateProgressBar to move the bar
' Call CloseProgressBar to return to your main UI window
Sub BeginImportingFiles()
	Dim i
	OpenProgressBar()
	UpdateLog &quot;Step 1 of 2&quot;, &quot;&quot;
	For i = 1 to 10
		Sleep 100
		UpdateLog &quot;Next Step&quot;, &quot;&quot; &amp; Time()
		UpdateProgressBar i*10, &quot;Step 1 of 2&quot;
	Next
	UpdateLog &quot;Step 1 of 2&quot;, &quot;Complete&quot;
	Sleep 2000
	CloseProgressBar()
End Sub

Sub Sleep(MSecs) 
	Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
	If Fso.FileExists(&quot;sleeper.vbs&quot;)=False Then
	Set objOutputFile = fso.CreateTextFile(&quot;sleeper.vbs&quot;, True)
	objOutputFile.Write &quot;wscript.sleep WScript.Arguments(0)&quot;
	objOutputFile.Close
	End If
	CreateObject(&quot;WScript.Shell&quot;).Run &quot;sleeper.vbs &quot; &amp; MSecs,1 , True
End Sub

&lt;/script&gt;
&lt;script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot;&gt;
function OpenProgressBar()
{
	document.getElementById(&quot;gui&quot;).style.display=&quot;none&quot;;
	document.getElementById(&quot;progressbargui&quot;).style.display=&quot;block&quot;;
}

function UpdateLog(text, status)
{
	var log = document.getElementById(&quot;log&quot;);
	if(status &amp;&amp; status != &quot;&quot;)
	{
		var maxLength = 33;
		var dotlength = maxLength - (text.length + status.length);
		var dots = &quot;&quot;;
		for(i = 0;i&lt;dotlength;i++)
			dots += &quot;.&quot;;
		log.value += text + dots + &quot;[&quot; + status + &quot;]\n&quot;;
	}
	else
		log.value += &quot;[&quot; + text + &quot;]&quot; + &quot;\n&quot;;
	log.scrollTop = log.scrollHeight;
}

function UpdateProgressBar(percentComplete, title, status)
{
	for(i = 1; i &lt;= 100; i++)
	{
		if((percentComplete) &gt;= i)
			document.getElementById(&quot;pbar&quot;+i).className = &quot;pbarcomplete&quot;;
		else
			document.getElementById(&quot;pbar&quot;+i).className = &quot;pbar&quot;;
		document.title = title &amp;&amp; title != &quot;&quot; ? title : percentComplete + &quot;% Complete&quot;;
		document.getElementById(&quot;progresstitle&quot;).innerText = status &amp;&amp; status != &quot;&quot; ? status : percentComplete + &quot;% Complete&quot;;
	}
}

function CloseProgressBar()
{
	document.getElementById(&quot;gui&quot;).style.display=&quot;block&quot;;
	document.getElementById(&quot;progressbargui&quot;).style.display=&quot;none&quot;;
	UpdateProgressBar(0,&quot;&quot;,&quot;&quot;);
	document.getElementById(&quot;log&quot;).value = &quot;&quot;;
}
&lt;/script&gt;
&lt;script language=&quot;VBScript&quot; type=&quot;text/vbscript&quot;&gt;
'Progress Bar Logic
&lt;/script&gt;
&lt;style type=&quot;text/css&quot;&gt;
body,html {
	margin:auto;
}
div#progressbar{
border:1px solid #ccc;
margin:0px;padding:0px;
}
span.pbar{
	width:3px;
	margin:0px;
	padding:0px;
	border-left:1px solid #fff;
	background:#fff;
	line-height:5px;
	height:16px;
	font-size:2px;
}
span.pbarcomplete{
	width:3px;
	margin:0px;
	padding:0px;
	border-right:1px solid #ccc;
	background:green;
	line-height:5px;
	height:16px;
	font-size:2px;
	
}
table {
	width:100%;
	height:100%;
}
table td {
	text-align:center;
	vertical-align:center;
}
table td.progressbargui {
	display:none;
	vertical-align:top;
}
textarea#log{
	width:100%;
	height:100px;
	border:1px solid #aaa;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;table&gt;
&lt;tr&gt;
	&lt;td id=&quot;gui&quot;&gt;&lt;input type=&quot;button&quot; onclick=&quot;BeginImportingFiles()&quot; value=&quot;Begin File Import&quot;/&gt;&lt;/td&gt;
	&lt;td id=&quot;progressbargui&quot; class=&quot;progressbargui&quot;&gt;
		&lt;div id=&quot;progresstitle&quot;&gt;&amp;nbsp;&lt;/div&gt;
		&lt;div id=&quot;progressbar&quot;&gt;
		&lt;script type=&quot;text/javascript&quot;&gt;
		for(i = 1; i &lt;= 100; i++)
			document.write(&quot;&lt;span id=\&quot;pbar&quot; + i + &quot;\&quot; class=\&quot;pbar\&quot;&gt;&lt;/span&gt;&quot;);
		&lt;/script&gt;
		&lt;/div&gt;
		&lt;textarea id=&quot;log&quot;&gt;&lt;/textarea&gt;
	&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;/body&gt;
&lt;/html&gt;

</pre>
<p>Some potentially useful links dealing with HTA:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/ms536496%28VS.85%29.aspx" target="_blank">HTML Applications Introduction</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/ms536473%28VS.85%29.aspx" target="_blank">HTA Reference</a></li>
<li><a href="http://www.amazon.com/gp/product/0735622442?ie=UTF8&#038;tag=cheesymovieni-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0735622442" target="_blank">Advanced VBScript for Microsoft  Windows  Administrators (Book)</a><img src="http://www.assoc-amazon.com/e/ir?t=cheesymovieni-20&#038;l=as2&#038;o=1&#038;a=0735622442" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>https://www.northatlantawebdesign.com/index.php/2009/07/17/hta-progress-bar-using-vbscript-and-javascript/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Simple VBScript Progress Bar</title>
		<link>https://www.northatlantawebdesign.com/index.php/2009/07/16/simple-vbscript-progress-bar/</link>
		<comments>https://www.northatlantawebdesign.com/index.php/2009/07/16/simple-vbscript-progress-bar/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 17:26:17 +0000</pubDate>
		<dc:creator><![CDATA[Jeff Gibeau]]></dc:creator>
				<category><![CDATA[VBScript]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Progress Bar]]></category>

		<guid isPermaLink="false">http://www.northatlantawebdesign.com/?p=69</guid>
		<description><![CDATA[Recently I had a need for a simple progress bar written in VBScript to let users know what was going on in a multi-step application. To my surprise, VBScript has nothing built in for a progress bar.  After much searching, I was able to find this thread that linked to yet another thread with a [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Recently I had a need for a simple progress bar written in <a type="amzn">VBScript</a> to let users know what was going on in a multi-step application.  To my surprise, VBScript has nothing built in for a progress bar.  After much searching, I was able to find <a title="Copy Files with Progress Bar" href="http://www.tek-tips.com/viewthread.cfm?qid=1196550&amp;page=1">this thread</a> that linked to yet <a title="Adding some kind of progress" href="http://www.tek-tips.com/viewthread.cfm?qid=898604">another thread</a> with a simple progress bar done in HTML using InternetExplorer.Application.  I have taken this code and modified it to show an actual progess bar, with percentages, that can be updated as desired.  I&#8217;ve wrapped it up in a nice easy-to-use class for reusability.  Enjoy!</p>
<p><span id="more-69"></span></p>
<div id="attachment_82" style="width: 322px" class="wp-caption aligncenter"><img class="size-full wp-image-82" title="Simple VBScript Progress Bar" src="http://www.northatlantawebdesign.com/wp-content/uploads/2009/07/vbscript_progress_bar.gif" alt="Simple VBScript Progress Bar" width="312" height="99" /><p class="wp-caption-text">Simple VBScript Progress Bar</p></div>
<p>VBScript Progress Bar Class:</p>
<pre class="brush: vb; title: ; notranslate">
Class ProgressBar
Private m_PercentComplete
Private m_CurrentStep
Private m_ProgressBar
Private m_Title
Private m_Text
Private m_StatusBarText

'Initialize defaults
Private Sub ProgessBar_Initialize
m_PercentComplete = 0
m_CurrentStep = 0
m_Title = &quot;Progress&quot;
m_Text = &quot;&quot;
End Sub

Public Function SetTitle(pTitle)
m_Title = pTitle
End Function

Public Function SetText(pText)
m_Text = pText
End Function

Public Function Update(percentComplete)
m_PercentComplete = percentComplete
UpdateProgressBar()
End Function

Public Function Show()
Set m_ProgressBar = CreateObject(&quot;InternetExplorer.Application&quot;)
'in code, the colon acts as a line feed
m_ProgressBar.navigate2 &quot;about:blank&quot; : m_ProgressBar.width = 315 : m_ProgressBar.height = 40 : m_ProgressBar.toolbar = false : m_ProgressBar.menubar = false : m_ProgressBar.statusbar = false : m_ProgressBar.visible = True
m_ProgressBar.document.write &quot;&lt;body Scroll=no style='margin:0px;padding:0px;'&gt;&lt;div style='text-align:center;'&gt;&lt;span name='pc' id='pc'&gt;0&lt;/span&gt;&lt;/div&gt;&quot;
m_ProgressBar.document.write &quot;&lt;div id='statusbar' name='statusbar' style='border:1px solid blue;line-height:10px;height:10px;color:blue;'&gt;&lt;/div&gt;&quot;
m_ProgressBar.document.write &quot;&lt;div style='text-align:center'&gt;&lt;span id='text' name='text'&gt;&lt;/span&gt;&lt;/div&gt;&quot;
End Function

Public Function Close()
m_ProgressBar.quit
m_ProgressBar = Nothing
End Function

Private Function UpdateProgressBar()
If m_PercentComplete = 0 Then
m_StatusBarText = &quot;&quot;
End If
For n = m_CurrentStep to m_PercentComplete - 1
m_StatusBarText = m_StatusBarText &amp; &quot;|&quot;
m_ProgressBar.Document.GetElementById(&quot;statusbar&quot;).InnerHtml = m_StatusBarText
m_ProgressBar.Document.title = n &amp; &quot;% Complete : &quot; &amp; m_Title
m_ProgressBar.Document.GetElementById(&quot;pc&quot;).InnerHtml = n &amp; &quot;% Complete : &quot; &amp; m_Title
wscript.sleep 10
Next
m_ProgressBar.Document.GetElementById(&quot;statusbar&quot;).InnerHtml = m_StatusBarText
m_ProgressBar.Document.title = m_PercentComplete &amp; &quot;% Complete : &quot; &amp; m_Title
m_ProgressBar.Document.GetElementById(&quot;pc&quot;).InnerHtml = m_PercentComplete &amp; &quot;% Complete : &quot; &amp; m_Title
m_ProgressBar.Document.GetElementById(&quot;text&quot;).InnerHtml = m_Text
m_CurrentStep = m_PercentComplete
End Function

End Class
</pre>
<p>Example of Usage:</p>
<pre class="brush: vb; title: ; notranslate">
'Declare progressbar and percentage complete
Dim pb
Dim percentComplete
'Setup the initial progress bar
Set pb = New ProgressBar
percentComplete = 0
pb.SetTitle(&quot;Step 1 of 5&quot;)
pb.SetText(&quot;Copying bin/Debug Folder&quot;)
pb.Show()

'Loop to update the percent complete of the progress bar
'Just add the pb.Update in your code to update the bar
'Text can be updated as well by pb.SetText
Do While percentComplete &lt;= 100
wscript.sleep 500
pb.Update(percentComplete)
percentComplete = percentComplete + 10
Loop
wscript.sleep 3000

'This shows how you can use the code for multiple steps
'In a future iteration I will add a second bar to measure overall progress
percentComplete = 0
pb.SetTitle(&quot;Step 2 of 5&quot;)
pb.SetText(&quot;Copying bin/Release Folder&quot;)
pb.Update(percentComplete)
Do While percentComplete &lt;= 100
wscript.sleep 500
pb.Update(percentComplete)
percentComplete = percentComplete + 10
Loop
pb.Close()
wscript.quit
</pre>
<p>In a future release, I may add another progress bar to keep track of the steps that are completed.  Feel free to use and modify this code as you desire.</p>
<p>Useful Links:</p>
<ul>
<li><a title="Microsoft VBScript Reference" href="http://msdn.microsoft.com/en-us/library/d1wf56tt%28VS.85%29.aspx">Microsoft VBScript Reference</a></li>
<li><a title="W3Schools VBScript Reference" href="http://www.w3schools.com/Vbscript/default.asp">W3Schools VBScript Reference</a></li>
<li><a title="Copy Files with a Progress Bar" href="http://www.tek-tips.com/viewthread.cfm?qid=1196550&amp;page=1">Copy Files with a Progress Bar</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>https://www.northatlantawebdesign.com/index.php/2009/07/16/simple-vbscript-progress-bar/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
