View Single Post
 
Old 02-19-2020, 10:28 PM
Jennifer Murphy's Avatar
Jennifer Murphy Jennifer Murphy is offline Windows XP Office 2007
Competent Performer
 
Join Date: Aug 2011
Location: Silicon Valley
Posts: 234
Jennifer Murphy is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
If you declare an array, you need to populate it with code like:
I thought the way to declare a dynamic array was with
Code:
Dim varname() . . .
But this code
Code:
Dim sLiteBlue As String
sLiteBlue = "219,229,241"
Dim RGBVals
RGBVals = Split(sLiteBlue, ",")
results in RGBVals being a 3-element array,
Code:
?rgbvals(0)
219
?rgbvals(1)
229
?rgbvals(2)
241
so that this code gets me the integer RGB value:

Code:
?RGB(RGBVals(0), RGBVals(1), RGBVals(2))
15853019
I don't understand why adding the "()" to the Dim statement causes an error.

Quote:
It's not apparent why you'd want to go down the array path for RGB values, though, whichever approach you take.
Because I want to declare the highlight color as a string ("219,229,241") and then convert it to the integer value:

Code:
Dim sLiteBlue As String
sLiteBlue = "219,229,241"
Dim iLiteBlue As Long
Dim RGBVals As Variant
RGBVals = Split(sLiteBlue, ",")
iLiteBlue = RGB(RGBVals(0), RGBVals(1), RGBVals(2))
If there is a better way to convert sLiteBlue ("219,229,241") to 15853019, I'd be happy to use it.
Reply With Quote