When the user clicks a radio button from the Body Attributes group box,
we need to display its color on the Preview panel. When a particular button
is clicked, we will
retrieve the color of its font from the Body text box, translate that color
into red, green, and blue values, and then use those values to automatically
update the scroll bars and the edit boxes. While we are at it, we also need
to update the corresponding text box in the Body Attributes group box. Since
this functionality will be used by all radio buttons in the group, we will
use a global function to which we can pass two variables.
When the user clicks a particular radio button, that button is represented
by a text box in the lower-left Body section. We need to get the color of
that edit box and pass it to our function. Since the clicked radio button
has a corresponding text box in the Body Attributes group box, we need to
change/update that value with the hexadecimal value of the first argument.
Therefore, we will pass a String argument to our function.
In the module, create the following sub procedure:

Private Sub ClickOption(lngColor As Long, Result As String)
' These variables will hold the red, green, and blue
' values of the passed color
Dim iRed As Integer
Dim iGreen As Integer
Dim iBlue As Integer
' Colorize the Preview panel with the passed color
pnlPreview.BackColor = lngColor
' Get the red value of the color of the Preview panel
iRed = lngColor Mod 256
' Get the green value of the color of the Preview panel
iGreen = (lngColor / 256) Mod 256
' Get the blue value of the color of the Preview panel
iBlue = lngColor / 65536
' Now that we have the red, green, and blue values of the color,
'Update the scroll bars with the new values
scrRed.Value = iRed
scrGreen.Value = iGreen
scrBlue.Value = iBlue
' Update the red, green, and blue values
' of the Numeric Values group box
txtNumRed.Text = CStr(iRed)
txtNumGreen.Text = CStr(iGreen)
txtNumBlue.Text = CStr(iBlue)
'Update the string that was passed using
' the retrieved red, green, and blue values
Result = "#" & Hex(iRed) & Hex(iGreen) & Hex(iBlue)
End Sub