473,569 Members | 2,782 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Constant Expression Is Required Vb.Net 2008

I am trying to create an attribute of type Icon and have the following code:

<AttributeUsage (AttributeTarge ts.Class)_
Public Class PIMSGridViewIco nAttribute

Inherits System.Attribut e

'/// Private variables
Private oPiGridViewIcon As System.Drawing. Icon = Nothing

'/// Construtor
Public Sub New(ByVal Value As System.Drawing. Icon)
oPiGridViewIcon = Value
End Sub

'/// Public properties
Public ReadOnly Property GridViewIcon() As System.Drawing. Icon
Get
Return oPiGridViewIcon
End Get
End Property

End Class
And then on a class I attempt to set it to an icon within a resource file
with:

<PIMSGridViewIc on(My.Resources .resIcons.Team) _
However, this gives an error of "Constant expression is required.". Please
can someone advise what I am doing wrong and how I can set the attributes
value per class?

Kind regards

Rob

Jun 27 '08 #1
3 2599
Rob,

To Set a Property you need at least a Set
(

Set
oPiGridViewIcon = Value 'this is not the value from your constructor
but a key word
End Set

I would not use the keyword Value in the constructor as a reference

Cor

"Rob Blackmore" <ro*@robblackmo re.comschreef in bericht
news:87******** *************** ***********@mic rosoft.com...
>I am trying to create an attribute of type Icon and have the following
code:

<AttributeUsage (AttributeTarge ts.Class)_
Public Class PIMSGridViewIco nAttribute

Inherits System.Attribut e

'/// Private variables
Private oPiGridViewIcon As System.Drawing. Icon = Nothing

'/// Construtor
Public Sub New(ByVal Value As System.Drawing. Icon)
oPiGridViewIcon = Value
End Sub

'/// Public properties
Public ReadOnly Property GridViewIcon() As System.Drawing. Icon
Get
Return oPiGridViewIcon
End Get
End Property

End Class
And then on a class I attempt to set it to an icon within a resource file
with:

<PIMSGridViewIc on(My.Resources .resIcons.Team) _
However, this gives an error of "Constant expression is required.".
Please can someone advise what I am doing wrong and how I can set the
attributes value per class?

Kind regards

Rob
Jun 27 '08 #2
Not for attribute classes as you always set the value via the constructor?
"Cor Ligthert[MVP]" <no************ @planet.nlwrote in message
news:B3******** *************** ***********@mic rosoft.com...
Rob,

To Set a Property you need at least a Set
(

Set
oPiGridViewIcon = Value 'this is not the value from your constructor
but a key word
End Set

I would not use the keyword Value in the constructor as a reference

Cor

"Rob Blackmore" <ro*@robblackmo re.comschreef in bericht
news:87******** *************** ***********@mic rosoft.com...
>>I am trying to create an attribute of type Icon and have the following
code:

<AttributeUsag e(AttributeTarg ets.Class)_
Public Class PIMSGridViewIco nAttribute

Inherits System.Attribut e

'/// Private variables
Private oPiGridViewIcon As System.Drawing. Icon = Nothing

'/// Construtor
Public Sub New(ByVal Value As System.Drawing. Icon)
oPiGridViewIcon = Value
End Sub

'/// Public properties
Public ReadOnly Property GridViewIcon() As System.Drawing. Icon
Get
Return oPiGridViewIcon
End Get
End Property

End Class
And then on a class I attempt to set it to an icon within a resource file
with:

<PIMSGridViewI con(My.Resource s.resIcons.Team )_
However, this gives an error of "Constant expression is required.".
Please can someone advise what I am doing wrong and how I can set the
attributes value per class?

Kind regards

Rob
Jun 27 '08 #3
You mean that your attribute is a constant?

Cor

"Rob Blackmore" <ro*@robblackmo re.comschreef in bericht
news:47******** *************** ***********@mic rosoft.com...
Not for attribute classes as you always set the value via the constructor?
"Cor Ligthert[MVP]" <no************ @planet.nlwrote in message
news:B3******** *************** ***********@mic rosoft.com...
>Rob,

To Set a Property you need at least a Set
(

Set
oPiGridViewIcon = Value 'this is not the value from your constructor
but a key word
End Set

I would not use the keyword Value in the constructor as a reference

Cor

"Rob Blackmore" <ro*@robblackmo re.comschreef in bericht
news:87******* *************** ************@mi crosoft.com...
>>>I am trying to create an attribute of type Icon and have the following
code:

<AttributeUsa ge(AttributeTar gets.Class)_
Public Class PIMSGridViewIco nAttribute

Inherits System.Attribut e

'/// Private variables
Private oPiGridViewIcon As System.Drawing. Icon = Nothing

'/// Construtor
Public Sub New(ByVal Value As System.Drawing. Icon)
oPiGridViewIcon = Value
End Sub

'/// Public properties
Public ReadOnly Property GridViewIcon() As System.Drawing. Icon
Get
Return oPiGridViewIcon
End Get
End Property

End Class
And then on a class I attempt to set it to an icon within a resource
file with:

<PIMSGridView Icon(My.Resourc es.resIcons.Tea m)_
However, this gives an error of "Constant expression is required.".
Please can someone advise what I am doing wrong and how I can set the
attributes value per class?

Kind regards

Rob
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
4738
by: hemal | last post by:
I came across a very strange situation at work. There is an order of magnitude difference in execution time for the following two queries (10 v/s ~130 msec): select count(*) from table_name where column_name = 'value' or 1 = 0 select count(*) from table_name where column_name = 'value' I do not want to go into the reason why the...
9
3940
by: pvinodhkumar | last post by:
The number of elemets of the array, the array bound must be constant expression?Why is this restriction? Vinodh
13
2554
by: devdatta_clc | last post by:
Hi C experts I've a bunch of questions. Consider this simplified piece of code. const int a = 10; int main () { static int b = a;
22
3586
by: Tomás Ó hÉilidhe | last post by:
I've been developing a C89 microcontroller application for a while now and I've been testing its compilation using gcc. I've gotten zero errors and zero warnings with gcc, but now that I've moved over to the micrcontroller compiler I'm getting all sorts of errors. One thing I'd like to clarify is the need (in C89) for a compile- time...
7
2799
by: John Koleszar | last post by:
Hi all, I'm porting some code that provides compile-time assertions from one compiler to another and ran across what I believe to be compliant code that won't compile using the new compiler. Not naming names here to remove bias - I'm trying to tell if I'm relying on implementation defined behavior or if this is a bug in the new compiler. ...
7
4253
by: Hendrik Schober | last post by:
Hi, this #include <string> class test { typedef std::string::size_type size_type; static const size_type x = std::string::npos; }; doesn't compile using either VC9 ("expected constant expression") or Comeau Online ("constant value is not known"). If I replace
56
6687
by: Adem | last post by:
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" The C++ Standard (ISO/IEC 14882, Second edition, 2003-10-15) says under 6.4.2(2) : case constant-expression : I propose that the case expression of the switch statement be changed from "integral constant-expression" to...
8
20400
by: Stefano Sabatini | last post by:
Hi all, I'm encountering this while trying to implement a factory singleton method to generate objects. The singleton has a static map which binds a static creation function defined in each class to the type of the object to be created. Here it is the code, which is a modification of the wikipedia C++ factory example code: ...
8
13395
by: PJ6 | last post by:
Const factor As Double = Math.Sqrt(3) / 6 Error 1 Constant expression is required. This looks like laziness to me. In SQL Server, functions are given a distinction between ones that always return the same result for the same input, and those that can change. All (?) of the functions in Math are of the former type and should be allowed to...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8120
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7672
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7968
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6283
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.