WebsStyle as property

I’m tying to set a property in a WebContainer Control.

The constant is set up as follows.

DisplayStyle as WebStyle = MyStyle

MyStyle is a valid Style in the project.

When I compile I get : A consant was expected here, but this is some other kind of expression.

What am I Missing?

You can’t define a constant using an object like that. Constants must be defined as a literal, like a string, a number, etc…

OK.

My confusion arrises from the fact that the IDE allows me to set a constant as a Database. It even changes the icon of the property to a database.

It this unintended behavior: Or is there a way to define the constant as a database?

How are you doing this ?
When you add a constant to an item you have 4 choices - Number , String Boolean & Color
So I’m not sure how you’re adding this “constant as a database”
In a project if you add a database (named very cleverly as db) and in code you write

const mydb as SQLiteDatabase = db this wont compile as “db” is not a constant expression (basically a literal)

If you define a property on a Class as

property mydb as SQLiteDatabase = db
this wont compile as “db” is not a constant expression (basically a literal)

So I’m really not sure what it is you’re trying to do

Total Brain Fart.

I meant Property not constant.

Doh!

I’m tying to set a property in a WebContainer Control.

The PROPERTY is set up as follows.

DisplayStyle as WebStyle = MyStyle
MyStyle is a valid Style in the project.

When I compile I get : A consant was expected here, but this is some other kind of expression.

What am I Missing?

You cannot set a property’s default value in this way. Just like you cannot do this:

MyWindow As Window = Window1

Default values can only be set for intrinsic types, not classes or special things like Styles.

[quote=15469:@Jay Menna]I’m tying to set a property in a WebContainer Control.

The PROPERTY is set up as follows.

DisplayStyle as WebStyle = MyStyle
MyStyle is a valid Style in the project.

When I compile I get : A consant was expected here, but this is some other kind of expression.

What am I Missing?[/quote]

That the default value has to be a constant value (or literal like “this is” or 123)
The default value for an object CAN’T be an object instance as that requires creating one - which you cannot do as part of the default