say I have this:
Enum Alpha
A
B
C
End Enum
Is there a way to do this same thing without using Cint:
Dim val As Ineger = CInt(Alpha.A)
:rolleyes:
Printable View
say I have this:
Enum Alpha
A
B
C
End Enum
Is there a way to do this same thing without using Cint:
Dim val As Ineger = CInt(Alpha.A)
:rolleyes:
It returns integer as default datatype . So you don't have to convert it .Quote:
Originally posted by MrPolite
say I have this:
Enum Alpha
A
B
C
End Enum
Is there a way to do this same thing without using Cint:
Dim val As Ineger = CInt(Alpha.A)
:rolleyes:
VB Code:
Dim val As Ineger = Alpha.A
Heres an example of an enum.
VB Code:
Friend Enum enumDatabaseType As Byte DBAccess97 = 1 DBAccess2000 = 2 DBSQLServer = 3 End Enum
When you use it, its not a number, or an integer, its an enum type. If you do "MyVal.ToString" it will result in "DBAccess2000" for example, but if you want the number, it will convert it for you (as the format you specify like above).
NOQuote:
Originally posted by Grimfort
When you use it, its not a number, or an integer, its an enum type. If you do "MyVal.ToString" it will result in "DBAccess2000" for example, but if you want the number, it will convert it for you (as above).
Enum are basically integral values . If you didn't provide the values for each one , they start counting from zero . Remember Enums can't be string values but can be converted to string as you just did .
May I suggest you read this:
http://support.microsoft.com/default...n-us;311327#1e
Main part being:
Enumerators are value types that have their own set of methods.
You can also use them alongside reflection to use things like ModuleBuilder.DefineEnum, and EnumBuilder.DefineLiteral (Ive not used them personally tho).
Edit: Notice the edit in the post b4, I wanted to make it more clear.
I can't see any relation to the problem presented here . The point is : No explicity conversion is needed since the default type of declared enum is integer .Quote:
Originally posted by Grimfort
May I suggest you read this:
http://support.microsoft.com/default...n-us;311327#1e
Main part being:
Enumerators are value types that have their own set of methods.
You can also use them alongside reflection to use things like ModuleBuilder.DefineEnum, and EnumBuilder.DefineLiteral (Ive not used them personally tho).
Edit: Notice the edit in the post b4, I wanted to make it more clear.
I agree. What were you saying no to then ? I just said that an enum is of type enum, that automatically converts to the declared format.
I said no because conversion isn't necessary her (as you did).Quote:
Originally posted by Grimfort
When you use it, its not a number, or an integer, its an enum type. If you do "MyVal.ToString" it will result in "DBAccess2000" for example, but if you want the number, it will convert it for you (as the format you specify like above).
Thats why I edited my post, it wasnt clear enough. I thought you were saying no, that an enum was not a type, but "basically integral values". :blush: I didnt mean to sound shirty.
aah you too stop arguing:D
hehe I didnt know I can get by it without CInt :p hehe thanks
It was a technical discussion :). Nothing like a little heat to warm the forums.