ConsoleProgressBar - Simple Progress Bar Function for your VB.Net Console Application
Posted by Daniel - 9,440 Views
It is good to know that long process is still ticking and one of the best way to provide the indicator is to have a progress bar. I am pretty sure you already knew how to display progress bar when you deal with windows form application but what about console application, is there any progress bar component which can be easily incorporated into the console screen?
I’ve searched the internet to find this kind of stuff but I found nothing (let me know if I am wrong), so there is no other way than to create it myself and here it is: my own progress bar for console application written in VB.Net.
It’s very simple. I use a single sub procedure instead of packing it as a class since I don’t think it’s required. A sub procedure called RenderProgressBar is the only procedure responsible to process and render the progress bar on the console screen.
There are two options you can use with this function. The first one is to display the progress bar with maximum limit specified. With this option the percentage of process and the “bar” itself will be displayed. The second one is displaying the progress without specifying the max limit so there is no “bar” with this option, it will only display the iteration value - it’s good when you have no idea when a process will be completed but you still want to show that the process is still ticking.
Following is the RenderProgressBar code:
Dim strResult As String
Dim intPercent As Integer
If (intMaxValue > 0) Then
intPercent = Math.Round((intProgress / intMaxValue) * 100, 0)
If intPercent >= 10 Then
strResult = “| “ & intPercent & “% |” & StrDup(intPercent \ 10, “=”) & StrDup(10 - (intPercent \ 10), ” “) & “|”
Else
strResult = “| “ & intPercent & “% |” & StrDup(10, ” “) & “|”
End If
Else
intPercent = intProgress
strResult = “| “ & FormatNumber(intPercent, 0) & ” |”
End If
Console.CursorVisible = False
Console.SetCursorPosition(intLeftPos, intTopPos)
Console.Write(strResult)
Console.CursorVisible = True
End Sub
The demo project along with the RenderProgressBar sub procedure is included in this post. Feel free to enhance this function as you wish, in fact I encourage you to do it. You may pack it as a class or anything as long as it gets better. Good luck :)
Available Download:
__________________________
The following posts are programmatically considered as related to the current post by YARPP Plugin:
- Passing arguments to your VB.NET console application
- How to Get User Input and allowing more than 256 characters to be entered on .NET Console Application
- Bringing the Lovely VBScript Split Function into Delphi with a Custom Function
- Runtime-Form-Creation. Automatically creating child forms in a Delphi MDI application with a component array
- Visual Basic.NET, an example of using HTTPWebRequest object
Related posts brought to you by Yet Another Related Posts Plugin.
Latest from Programming
- Microsoft Excel Import External Data Problem: When Microsoft Query doesn’t recognize some of your parameters
- SmartImageResizer Plugin, WordPress plugin based on Joe Lencioni’s Smart Image Resizer
- Resize Image or Crop Image with Joe Lencioni’s Smart Image Resizer, WordPress Setup
- Free Softwares to help you learn Regular Expression or to enhance your RegEx skill
- ConsoleProgressBar - Simple Progress Bar Function for your VB.Net Console Application
One Response to “ConsoleProgressBar - Simple Progress Bar Function for your VB.Net Console Application”
Leave a Reply
Latest Blog Entries
- Sweet Home 3D, a free home design software
- 26x Optical Zoom on a Compact Digital Camera?
- Windows 7 Release Candidate is now available
- Microsoft Excel Import External Data Problem: When Microsoft Query doesn’t recognize some of your parameters
- The Lack of Chances is the Source of Poverty, Can we make a different?
- SmartFTP Client is no longer Free. What would be the best replacement for it?
- Kantaris Media Player, The most suitable Free Media Player on my Audio Environment
Categories
Neighbours and Friends
- Anti Teori
- Busby SEO Test Page
- Deny Sri
- Digital Media Convert
- Freeware Maniac
- Oeroek
- RidhoCyber
- Suraja Web
Comments - Thanks Guys :)
Therese Lachance: Hi, Any idea how to have ContuttoPDF fetch the correct page language?
Marlena Albu: Super Blog, Dude! I am constantly on the watch for new and interesting sites and postings about audio equipment… which is what...
tresloukadu: yo how did u fixed when the tags shows <? and it shows < “& l t ; ” ?? please send me an email.
Sean: This is a great piece of code and thanks for adding the updates. Sean’s last blog post: Not All Text Message Marketing Is Created...
rodhy: Thank for your code, it very usefull for me. best regard.
Most Popular Entries
- Passing arguments to your VB.NET console application
- ConsoleProgressBar - Simple Progress Bar Function for your VB.Net Console Application
- ASCII To PDU Converter (Convert ASCII to PDU and vice versa)
- An example: Using CPort Delphi Component to read data from your cellphone
- Microsoft Excel Import External Data Problem: When Microsoft Query doesn’t recognize some of your parameters
Software Collections
- Sweet Home 3D, a free home design software
- SmartFTP Client is no longer Free. What would be the best replacement for it?
- Kantaris Media Player, The most suitable Free Media Player on my Audio Environment
- TCPView for Windows, Tool to check TCP and UDP Connections on your system
- The Code Snippet Plugin, my favourite syntax highlighter plugin for WordPress
Blogging Related Stuff
- Change the WordPress permalink structure to the best format, and yes it’s a little bit scary :D
- Something is wrong, the Google Search Result from my blog looks bad, don’t laugh please :D
- Several tips to reduce Blog Noise, especially when your blog covers more than one niche
- How to remove your indexed pages or even your entire site from Google and Yahoo!


















March 16th, 2008 at 5:51 am
Nice tip, nice snippet. Console apps rock!
JohnnyIdol’s last blog post: [C++] How to disable Alt+Tab (and other key combinations)