Results 1 to 5 of 5

Thread: transforming vb colors to html?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    Wayne just answered my question on how to get the palette to open, now how do I made it so that it takes the color, convers it into HTML then puts the HTML color code into a textbox
    NXSupport - Your one-stop source for computer help

  2. #2
    Guest
    Take a look at this thread.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    Thanks, matt, but its kinda confusing, do I add all of that to a module? and do I call to the functions?

    can you please like change it a little so that you put in a VB color (i.e. &h001&) into text1 and have it say the html color in text2
    NXSupport - Your one-stop source for computer help

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Here's a little function you can use:
    Code:
    Public Function GetHTMLColor(p_Color As Long) As String
        Dim strBuffer As String
        Dim intLen As Integer
        Dim intPad As Integer
        
        strBuffer = Hex(p_Color)
        
        Select Case Len(strBuffer)
            Case 1
                intPad = 5
            Case 2
                intPad = 4
            Case 3
                intPad = 3
            Case 4
                intPad = 2
            Case 5
                intPad = 1
        End Select
        
        GetHTMLColor = "#" & String(intPad, "0") & strBuffer
    End Function

    Then you can call this function like this:
    Code:
    Private Sub Command1_Click()
        Dim strHTMLColor As String
        
        strHTMLColor = GetHTMLColor(RGB(10, 125, 255))
        MsgBox strHTMLColor
    End Sub

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Or might be easier if you just
    Code:
    strHTMLcolor = "#" & Right("00000" & Hex(Color),5)
    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.

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