Results 1 to 4 of 4

Thread: Decimal colors to html-ish hex?

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Posts
    2

    Post

    Me and my friend are making a html editor, just for fun, and we can't get out of this problem:

    If we take the commondialog hexidecimal color, how can you convert it to html hex like #FF4455?
    I tried hex$(color) where color is a long, the commondialog color returned..
    But however, that didn't work. It looks like vb is deleting the 0(s), and only printing F(s), 8(s) and 0(s)..does anyone know how to solve this problem?

    Thanks.

  2. #2
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Leeds, UK
    Posts
    287

    Post A program I made

    Hi,

    I made a program that does that a bit ago, it isn't great but it works:

    Program (EXE): Download

    Try this program and if its what you want then I will upload the source aswell. There is not much point in me doing that if its not what you want.





    Edited by rino_2 on 02-27-2000 at 11:18 AM

  3. #3
    Addicted Member
    Join Date
    Jul 1999
    Posts
    219

    Post

    here try this it does the last couple of letter of the html color here you can figure out the rest

    Code:
    Private Sub HScroll1_Change()
    Dim I
    Dim b
    Dim C
    Picture1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
    Label1.Caption = "RGB(" & HScroll1.Value & "," & HScroll2.Value & "," & HScroll3.Value & ")"
    I = HScroll1.Value + Val(HScroll2.Value)
    b = I + Val(HScroll3.Value)
    Label2.Caption = Hex(b)
    End Sub
    
    Private Sub HScroll2_Change()
    Picture1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
    Label1.Caption = "RGB(" & HScroll1.Value & "," & HScroll2.Value & "," & HScroll3.Value & ")"
    I = HScroll1.Value + Val(HScroll2.Value)
    b = I + Val(HScroll3.Value)
    Label2.Caption = Hex(b)
    End Sub
    
    Private Sub HScroll3_Change()
    Picture1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
    Label1.Caption = "RGB(" & HScroll1.Value & "," & HScroll2.Value & "," & HScroll3.Value & ")"
    I = HScroll1.Value + Val(HScroll2.Value)
    b = I + Val(HScroll3.Value)
    Label2.Caption = Hex(b)
    End Sub

  4. #4

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Posts
    2

    Post

    Thanks for your kind help people, :)
    I'm going to try it..the hex codes already worked with rino's program

    But..if rino's code uses the same method as xxEvilx's code, then i don't understand why our code didn't work

    The code we used was:

    Private Sub Command1_Click()
    Dim color As Long
    CommonDialog1.ShowColor
    color = CommonDialog1.Color
    RichTextBox1.SelText = "<font color=#" & Hex$(color) & ">" & RichTextBox1.SelText & "</font>"
    End Sub

    ---Fquist
    fquist.hypermart.net


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