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
-
How to write a query set to excel using vb.net
by BarbaMariolino (1 replies)
-
Very Urgent regarding deleting the images from a folder
by rameshbandi (2 replies)
-
Block Accessing MSSQL 2000
by militia (0 replies)
-
.NET Developer in Ghana Required....
by sysview (0 replies)
-
Sending SMS to mobile using secure gateway from VB.net 2008 c#
by pratikasthana17 (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...
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.