Results 1 to 4 of 4

Thread: How can I convert VB Hex value 2 HTML Hex Value ?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Location
    Bangladesh
    Posts
    19

    Question

    Hey Guys!

    I'm in a big problem ! I'm making a prog. that takes some

    information from the user and generates a web page for

    him.It lets the user to select the BG ,TXT, LINK etc. color

    by a Common Dialog Color box.But the problem occurs when

    i'm trying to convert the LONG color code into HEX color

    code.It happens that the VB Hex color code value and the

    HTML Color code HEX value dosen't match.So if anyone solve

    the problem,i'll be glad ! Thanks

    e-mail me at : [email protected]
    emranHASAN

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Hey, I got some code here from the forum (can't remember who posted it, sorry )

    Code:
    Public Function RGBHexColor(lngColor As Long) As String
    Dim sHex As String
    sHex = Hex(lngColor)
    sHex = Right$("000000" & sHex, 6)
    sHex = Right$(sHex, 2) & Mid$(sHex, 3, 2) & Left$(sHex, 2)
    RGBHexColor = sHex
    End Function
    Will make the long RGB value to a html HexColor!
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  3. #3
    Lively Member
    Join Date
    Sep 2000
    Location
    NC, USA
    Posts
    102

    Wink

    Doh, you beat me to it. hehe. Well, I just figured it out but as Jop, just pointed out with the code the basic difference appears to be the order of the hex values for VB vs HTML. i.e.

    HTML #HexValue1HexValue2HexValue3
    VB &H00HexValue3HexValue2HexValue1&

    So to go from VB to HTLM you would strip off the leading "&H00", strip off the trailing "&", reverse the remainging three hex values and slap a "#" in front of them.

    Hope that helps,
    KillemAll

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Location
    Bangladesh
    Posts
    19

    Smile Thanks 2 Jop & KillemAll

    Thank you two very musch !

    I want to be friend with you two,if you want

    please mail me at [email protected]


    Bye ! Bye !
    emranHASAN

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