Visual Basic Programming Code Examples
Visual Basic > API and Miscellaneous Code Examples
Convert integer to Hex
Convert integer to Hex
'make a form with a commondialog.control
'make a command.control named cmdColor
Sub cmdColor_Click()
dim RedValue, GreenValue, BlueValue
dim AColor
'see help on Flags for settings
CMDialog1.Flags = &H1& Or &H4&
'action 3 means show colorpalette
CMDialog1.Action = 3
'when you press OKE the color will be put into the variable AColor
AColor = CMDialog1.Color
RedValue = (ACOLOR And &HFF&)
GreenValue = (ACOLOR And &HFF00&) \ 256
BlueValue = (ACOLOR And &HFF0000) \ 65536
ChoosenColor = Format(Hex(RedValue) & Hex(GreenValue) & Hex(BlueValue), "000000")
msgbox ChoosenColor
End Sub
Return