Results 1 to 4 of 4

Thread: Vb Color to HTML Color

  1. #1

    Thread Starter
    Addicted Member Tiovital's Avatar
    Join Date
    Apr 2000
    Posts
    249
    Hi,
    I was just wondering if there is a way to convert a VB color code to html color code ?

    Thanks


  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Vb color code is a decimal value stored in a long and html is a hex value stored in a string. just convert between them using
    Code:
    htmlcolor = Hex(vbcolor)
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Addicted Member Tiovital's Avatar
    Join Date
    Apr 2000
    Posts
    249
    Hi Kedaman,

    R U Sure? I try That and it is not the same.

    HtmlColor = hex(vbred)
    ???




  4. #4
    Member
    Join Date
    Jan 2000
    Posts
    35
    Code:
    Public Function FormatRGBString(val As Long) As String
        Dim color As String
        Dim pad As Long
        Dim r As String
        Dim g As String
        Dim b As String
        ' This function formats a long consisting of rgb values
        ' taken from the CommonDialog color dialog
        ' to a string in the form of "#RRGGBB" where RRGGBB are
        ' hex values
        ' convert to hex
        color = Hex(val)
        'determine how many zeros to pad in front of converted value
        pad = 6 - Len(color)
        If pad Then
            color = String(pad, "0") & color
        End If
        'Extract the rgb components
        r = Right(color, 2)
        g = Mid(color, 3, 2)
        b = Left(color, 2)
        ' Swab r and b position, color dialog returns
        ' bgr instead of rgb
        color = "#" & r & g & b
        FormatRGBString = color
    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width