Library code snippets
VB Express Color Object to Hex String
By Chris Buske, published on 05 May 2006
Code
This function takes a color object and returns the Hex value with a preceeding #.
Private Function ColorHex( ByVal color As Color) As String
Dim r As String = Hex(FColor.R), G As String = Hex(FColor.G), B As String = Hex(FColor.B)
If r.Length = 1 Then r = 0 & r : If G.Length = 1 Then G = 0 & G : If B.Length = 1 Then B = 0 & B
ColorHex = "#" & r & G & B
End Function
Related articles
Related discussion
-
Why choose c# when there is Java
by Thaj06 (0 replies)
-
Change color while typing in rich text box
by Akhtar Hussain (0 replies)
-
Third party components to enhance User Interface of Windows based application
by Shaila14041981 (0 replies)
-
VB.NET DataGridView Sort
by bradhen (0 replies)
-
About Comparison in Asp.Net
by S_Rahul (0 replies)
Related podcasts
-
xpert to Expert: Inside Concurrent Basic (CB)
"Concurrent Basic extends Visual Basic with stylish asynchronous concurrency constructs derived from the join calculus. Our design advances earlier MSRC work on Polyphonic C#, Comega and the Joins Library. Unlike its C# based predecessors, CB adopts a simple event-like syntax familiar to VB progr...
Check this hex to string function tool David
!--removed tag-->Yes, that gives you am html compatible string, or if you want the Hex version just do:
"#" + System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Green).ToString("X6")
In VB Express can you not use
Imports System.Drawing.ColorTranslator
Then just code
txtHtmlName.Text = ToHtml(cPreview.BackColor)
txtHtmlName.Text = Drawing.ColorTranslator.ToHtml(cPreview.BackColor)
Back to a color
cPreview.BackColor = Drawing.ColorTranslator.FromHtml(txtHtmlName.Text)
There are lots of color functions but I had to spend a lot of time finding good examples
Like
Imports System.Drawing.Color
cPreview.BackColor = FromArgb(c.Red, c.Green, c.Blue)
Just thought I would share these
David
This thread is for discussions of VB Express Color Object to Hex String.