Click here to Skip to main content
12,698,686 members (26,642 online)
Click here to Skip to main content
Add your own
alternative version


31 bookmarked

Get colors in your VB.NET console application

, 17 Jul 2003
Rate this:
Please Sign up or sign in to vote.
Use Windows APIs to write a console tool module, able to change your console background and foreground colors.
<!-- Article image -->

Sample Image - color_console.jpg

<!-- Add the rest of your HTML here -->


How can i use colors to make my console application look pretty with VB.NET ? I was writing a remoting server when this idea came ... So i've made this little module ! It was not really difficult to do but i think it could save your time ;)

How to use it ?

You can either change background and foregroud ...

ConsoleTools.SetConsoleColors(ConsoleColor.Green, ConsoleColor.DarkBlue)

... or just foreground :


How does it run ?

I just use kernel api's SetConsoleTextAttribute (to change colors) and GetStHandle (to retrieve console output handles). An enumeration has been created to have bases colors codes : enumeration values must be directly used to change foreground color, and enumeration values * 16 (mask) must be used to change foreground color.

So you just have now to use SetConsoleColors function (which use kernel's api) to change your console colors ...


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
France France
Actually software architect for a little company based in France (Rennes), I'm specialized in distributed applications. I work a lot with .net remoting but don't have enough time to write articles about it ...Frown | :(

You may also be interested in...


Comments and Discussions

Questionthanks for the jazz up Pin
Kobracode27-Oct-14 14:32
memberKobracode27-Oct-14 14:32 
Generalthanks! Pin
josephlawrencecarpio23-Mar-08 16:41
memberjosephlawrencecarpio23-Mar-08 16:41 
GeneralSmall bug Pin
PhiL6667-Dec-06 16:25
memberPhiL6667-Dec-06 16:25 
GeneralRe: Small bug Pin
madestro13-Dec-06 8:14
membermadestro13-Dec-06 8:14 
SuggestionRe: Small bug Pin
Wilfredo Gumersindo6-Sep-11 6:32
memberWilfredo Gumersindo6-Sep-11 6:32 
GeneralAstonishing Pin
nalt6519-Jan-06 22:53
membernalt6519-Jan-06 22:53 
GeneralCreata, but litle Error using Option Strict Pin
heck-17-Nov-05 22:18
memberheck-17-Nov-05 22:18 
GeneralConsole Code Colors Pin
brichard23-Jun-04 12:14
memberbrichard23-Jun-04 12:14 
QuestionIcons? Pin
Uwe Keim18-Jul-03 1:55
sitebuilderUwe Keim18-Jul-03 1:55 
AnswerRe: Icons? Pin
Roger J18-Aug-03 23:13
memberRoger J18-Aug-03 23:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170118.1 | Last Updated 18 Jul 2003
Article Copyright 2003 by ps1k0
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid