Export (0) Print
Expand All
Expand Minimize
2 out of 5 rated this helpful - Rate this topic

Converting VBScript's RGB Function


Windows PowerShell


Definition: Returns a whole number representing an RGB color value.

RGB

If you are a Web designer you might very well find yourself needing to calculate RGB color values. Although Windows PowerShell doesn't include a built-in method or function for calculating RGB values you can write a simple equation that will do the math for you. In the following example, we assign values to three different variables, representing the three color components: $blue, $green, $red. We then calculate the RGB value and store the result in the variable $a:


$blue = 10
$green= 10
$red = 10

$a = [long] ($blue + ($green * 256) + ($red * 65536))

When you run these commands and then echo back the value of $a you should get the following:


657930


Return to the VBScript to Windows PowerShell home page

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.