A recent thread on the forums discussed why a particular bit of code would not compile he felt the error message seemed less than helpful: “CRghtColr As Color = Color.RGBA(000,061,255,208)”.
CRightColr is set up as a shared color property. And the person wanted the default value to be set from the Color.RGBA function. When you try this you get an error.
Window1.CRghtColr Declaration Not enough arguments: got 0, expected 4. Private Shared CRghtColr As Color = Color.RGBA(000, 061, 255, 208)
It’s confusing as it’s not clear what requires more parameters. However, the User Guide quite clearly states that Constants can be assigned only a literal value, another constant value or the result of a constant expression.
A literal is easy – it’s something like &cFF00FF00 – a color literal. A constant value would be assigning one constant to another. Say you had another constant:
cColor as color = &cffffff00
You could then assign:
Private Shared CRghtColr As Color = cColor
And this would be fine.
A “constant expression” is a little less obvious here. It’s literally an expression made up only of constant values. This example should make it clearer:
Const constant1 as integer = 90 Const constant2 as integer = 100 Const constant3 as integer = constant1 + constant2 // constant1 + constant2 is a constant expression
Note that none of the allowable ways to set a constant include calling a function like Color.RGBA. Unfortunately while the compiler tries its best to make sense of what you’re trying to do, this one confuses it and you get this somewhat unhelpful error message.
So, if you ever happen to see this, check to see that you are following the rules about what is allowed for the default value of a constant.