Many software that do not require UI, we all think of developing it into a console program. But this is more written in the white text, not only the user can see tired, but even the developers feel that it is honest. Well, have you considering writing a flower-green console program, give people a new feeling? Come, follow Diy: Imports Systemimports System.Runtime.InteropServices
Module ModuleConsolecolors
Sub main ()
'Define a variable to get the handle DIM HOUT AS INTPTR' -11 specifically for the output device hout = getStdHandle (-11)
'Now demonstrate different text settings! SetConsoleTextAttRibute (HOUT, Textttributes.Background_INTENSITY) Console.Writeline ("Welcome to access 居: http://blog.9cbs.net/gnoyng :)") 'Note that the parameter value I passed in this statement is two The sum of the enumeration values, so their effects superimpose setconsoletexttattribute (HOUT, & H9) Console.writeline ("You must find what you like in 东 东 - ...") SetConsoleTextttribute (Hout, TextAttributes . Background_green) Console.writeline ("I often stare at the computer will damage the vision, so please take a look at the green thing.") SetConsoleTextttribute (Hout, TextAttributes.ForeGround_red) console.writeline ("I will tell you again - -There Is Not! ") SetConsoleTextAttribute (HOUT, Textttributes.Background_Blue) Console.Writeline (" I was born in the south of China, so I always like blue ... ")
'Exit console.read () by any key
End Sub
'Declaration SetConsoleTextttribute Function Declare Function SetConsoleTextttribute Lib "kernel32.dll" (_ byval hconsoleoutput as intptr, ByVal Wattributes as texttributes) AS Boolean
'Nurse getStdHandle function to get the handle Declare Function Getstdhandle lib "kernel32.dll" used in the SetConsoleTextAttribute function, AS INTPTR
'The enumeration of the text style, 淌 here just lists several of the most basic' overlapping the different enumeration values, you can get a synthetic style 'to try it, oh, the three original superimposed principle you It should be very clear, haha? Public Enum TextaTRibutes
FOREGROUND_BLUE = & H1 FOREGROUND_GREEN = & H2 FOREGROUND_RED = & H4 FOREGROUND_INTENSITY = & H8 BACKGROUND_BLUE = & H10 BACKGROUND_GREEN = & H20 BACKGROUND_RED = & H40 BACKGROUND_INTENSITY = & H80 COMMON_LVB_LEADING_BYTE = & H100 COMMON_LVB_TRAILING_BYTE = & H200 COMMON_LVB_GRID_HORIZONTAL = & H400 COMMON_LVB_GRID_LVERTICAL = & H800 COMMON_LVB_GRID_RVERTICAL = & H1000 COMMON_LVB_REVERSE_VIDEO = & H4000 COMMON_LVB_UNDERSCORE = & H8000End Enum
End module, it is called two API functions - the principle is actually very simple!