Converting integers to hex

  • Thread starter Thread starter Harry Hudini
  • Start date Start date
H

Harry Hudini

Hi,

I have a slider on a form, which i want to let the user use to change the
colour of the form.

In order to do this, i want to convert the value to hex, then pass that hex
in to the backcolor property of a form via an RGB command.

1) Is this an ok way of doing it?

2) it would seem the RGB command takes a series of Hex values, but how can
i convert the value param (integer) of the slider to a hex value ?

Olly
 
Numbers are numbers- they're all binary. Hex or deciaml is simply to make
readability more simple. There are no functions (other than conversions)
that differentiate them. Color.FromArgb simply takes 3 32-bit numbers.
 
Function ColorFromHexString(ByVal _vString As String) As Color
Return Color.FromArgb(RGB(Val("&h" & Mid(_vString, 5, 2)), _
Val("&h" & Mid(_vString, 3, 2)), _
Val("&h" & Mid(_vString, 1, 2))))

The string should have this format: FFFFFF00
 
Back
Top