Converting integers to hex

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
 
C

Chris Tacke, eMVP

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.
 
C

CTitanic

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top