CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2003
    Location
    Melbourne
    Posts
    27

    Convert string to hex value

    Hi,

    I'm saving the forecolor and backcolor of my labels to a text file as hex values...

    print #1, "lbl1.fc=" & Hex(label1.forecolor)
    print #1, "lbl1.bc=" & hex(label1.backcolor)

    Therefore, my file would look like

    lbl1.fc=80000012
    lbl1.bc=FFFFFF

    When I read those values back in, how do correctly insert those values to the forecolor and backcolor properties?

    The values are (at the moment) read in as a string, so how do I convert them to hex values without changing the value of the value?

    I can't say label1.forecolor = hex(80000012) because the number is already hex! I can't convert the string to a long because FFFFFF is not recognised as a number!

    Any clues appreciated.

    Thanks,

    Mark

  2. #2
    Join Date
    Jan 2003
    Location
    7,107 Islands
    Posts
    2,487
    Add the prefix "&H" into the string and use the cDec function :

    MsgBox cDec("&H" & sStringFromFile)
    Busy

  3. #3
    Join Date
    Mar 2003
    Location
    Melbourne
    Posts
    27
    Thanks Threadl! That did the trick!

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

Featured