Parsi Coders
Convert HTML Color to RGB - نسخه قابل چاپ

+- Parsi Coders (http://parsicoders.com)
+-- انجمن: Software Development Programming (http://parsicoders.com/forumdisplay.php?fid=37)
+--- انجمن: Visual Basic Programming (http://parsicoders.com/forumdisplay.php?fid=39)
+---- انجمن: Visual Basic 6 (http://parsicoders.com/forumdisplay.php?fid=44)
+---- موضوع: Convert HTML Color to RGB (/showthread.php?tid=1956)



Convert HTML Color to RGB - Amin_Mansouri - 03-24-2012

با سورس زیر میتونید رنگ html رو میتونید به Rgb تبدیل کنید.

In this day and age you will find yourself at times needing to set a color in two different ways. If you are doing any sort of web development you will find that often you are referring to colors using a code that looks something like this '#0066FF'. On the other hand if you are doing development in Visual Basic it expects you to specify any colors by their Red, Green, and Blue values (hence RGB). Luckily you can write a simple code snippet to convert HTML colors into their RGB equivalents.

To do this creat a new Visual Basic application. Add a command button to it. Double click this button. Highlight everything in the code editor and delete it. Replace it with this code.

کد:
Function HTMLtoRGB(HtmlCode As String) As String

        If Left(HtmlCode, 1) = "#" Then


                HtmlCode = Right(HtmlCode, 6)


        End If


        RED = Left(HtmlCode, 2)


        GREEN = Mid(HtmlCode, 3, 2)

        BLUE = Right(HtmlCode, 2)


        RgbHex = "&H00" + BLUE + GREEN + RED


        HTMLtoRGB = "&" & Val(RgbHex)


End Function


Private Sub Command1_Click()


    MsgBox HTMLtoRGB("0000FF")


End Sub