473,324 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Enums with spaces VB.NET

Hi

In VB6 you could declare and enumeration with spaces using the [enu
value] type syntax

I am now trying to implement an enum in VB.NET using this syntax and
am having an issue

Public Enum myEnu
EnumWithoutSpace
[Enum With Spaces
End Enu

Private Sub (ByVal a As myEnum
Select Case
Case myEnum.EnumWithoutSpace
'Do Somethin
Case myEnum.[Enum With Spaces
'Do Something Els
End Selec
End Su

I get the message "Identifier expected." at compile time. Any hel
would be appreciated

Regards

Willia


Nov 20 '05 #1
3 11899
* "=?Utf-8?B?V2lsbA==?=" <jo**@compot.ru> scripsit:
In VB6 you could declare and enumeration with spaces using the [enum
value] type syntax.

I am now trying to implement an enum in VB.NET using this syntax and I
am having an issue.

Public Enum myEnum
EnumWithoutSpaces
[Enum With Spaces]
End Enum

Private Sub (ByVal a As myEnum)
Select Case a
Case myEnum.EnumWithoutSpaces
'Do Something
Case myEnum.[Enum With Spaces]
'Do Something Else
End Select
End Sub

I get the message "Identifier expected." at compile time. Any help
would be appreciated.


The solution is not to use identifiers that contain spaces.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
Will - you can not use spaces in identifiers. See:

http://msdn.microsoft.com/library/de...ementNames.asp

or

http://msdn.microsoft.com/library/de...bspecstart.asp


"Will" <jo**@compot.ru> wrote in message
news:A7**********************************@microsof t.com...
Hi,

In VB6 you could declare and enumeration with spaces using the [enum
value] type syntax.

I am now trying to implement an enum in VB.NET using this syntax and I
am having an issue.

Public Enum myEnum
EnumWithoutSpaces
[Enum With Spaces]
End Enum

Private Sub (ByVal a As myEnum)
Select Case a
Case myEnum.EnumWithoutSpaces
'Do Something
Case myEnum.[Enum With Spaces]
'Do Something Else
End Select
End Sub

I get the message "Identifier expected." at compile time. Any help
would be appreciated.

Regards,

William


Nov 20 '05 #3
WIll,

As others have said, Identifiers cannot contain spaces.

In the case where you need spaces for display purposes (e.g. to display enum
values in a combo box), then you could add descriptive attributes to the
enum values (e.g. FriendlyName, Description etc.) and use these attributes
to get the information to display. Although doing it like this sorta
prevents you from using multiple languages for your UI though.

HTH,

Trev.

"Will" <jo**@compot.ru> wrote in message
news:A7**********************************@microsof t.com...
Hi,

In VB6 you could declare and enumeration with spaces using the [enum
value] type syntax.

I am now trying to implement an enum in VB.NET using this syntax and I
am having an issue.

Public Enum myEnum
EnumWithoutSpaces
[Enum With Spaces]
End Enum

Private Sub (ByVal a As myEnum)
Select Case a
Case myEnum.EnumWithoutSpaces
'Do Something
Case myEnum.[Enum With Spaces]
'Do Something Else
End Select
End Sub

I get the message "Identifier expected." at compile time. Any help
would be appreciated.

Regards,

William



Nov 20 '05 #4

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

Similar topics

13
by: SpaceCowboy | last post by:
I recently got into a discussion with a co-worker about using enums across a dll interface. He wanted to use chars instead, argueing that depending on compiler settings the size of an enum could...
2
by: Faisal | last post by:
Can anyone tell me if it is possible to enumerate through all the Enums within a class . I have a class with many Enums and would like to accees the Enums through an array/collection etc. I can't...
2
by: Zach Corera | last post by:
Is there anyway to put spaces in enum values in c#? In VB5 and VB6 you could say But that throws an error in c#
3
by: Curious | last post by:
Hi, I am trying to create the following enum: public enum myEnum {First Come First Serve, Shortest Job First, Round Robin} Now when I compile, errors are given. The main reason is that...
4
by: Martin Pritchard | last post by:
Hi, I'm working on a project that historically contains around 40 enums. In the database various fields refer to the int values of these enums, but of course ref integrity is not enofrced and...
1
by: Wlliam Cornwill | last post by:
Hi, In VB6 you could declare and enumeration with spaces using the type syntax. I am now trying to implement an enum in VB.NET using this syntax and I am having an issue. Public Enum...
2
by: Simon Elliott | last post by:
I have some legacy C++ code which requires some enums to be 1 or 2 bytes in size. I'd ideally like to be able to specify that a few carefully selected enums are a particular size. By default,...
11
by: Marc Gravell | last post by:
This one stumped me while refactoring some code to use generics... Suppose I declare an enum MyEnum {...} Is there a good reason why MyEnum doesn't implement IEquatable<MyEnum> ? Of course,...
3
by: Desmond Cassidy | last post by:
I created an Enum with the EnumBuilder which allows you to add items with spaces embedded as well as the name of the Enum. e.g. US States and a member of New York The normal way you would iterate...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.