Newbie question


N

Newbie

I have been trying to lear vb.net and I cannot remeber how to do
something that I read about a week ago and it is trying me crazy

You now how if you creat a vriable that is boolean whe you type in X
= the tru or false choice comes up. I want to creat a variable that
is a string but can only exsit in three states top middle and bottom.
I forgot how to do it. Sorry for this stupid question
 
Ad

Advertisements

S

Scott M.

Public Enum CurrentState
top
middle
bottom
End Enum

Public x As CurrentState
x = (you will get the intellisense dropdown here)
 
N

Newbie

Thanks that helps a lot. Is there any way to do it as a string
instead of an integer?
 
C

Cor Ligthert [MVP]

Can you give us a sample, in my idea is Scott's answer exact the answer on
your question.

Cor
 
M

Master Programmer

Hi Aaron

Try this.....

Public Class MyClass

Public Enum MyEnum
Dog
Cat
Pig
End Enum

Private _Animal As MyEnum


<Category("My Category"), DefaultValue(GetType(MyEnum), "Dog")> _
Property [Animal]() As MyEnum
Get
Return _Animal
End Get
Set(ByVal Value As MyEnum)
_Animal = Value
End Set
End Property


' ********************
' To grab it after at runtime....

' If Animal = MyEnum.Dog then
'
' End If


End Class


The Grand Master
 
S

Scott M.

I don't know how this address the string question, but no Aaron, Strings are
not allowed as enum types. You could, of course, write your own case
statement (if there aren't a lot of Enum choices) to test an Enum value and
assign a different variable according to that Enum value.


Master Programmer said:
Hi Aaron

Try this.....

Public Class MyClass

Public Enum MyEnum
Dog
Cat
Pig
End Enum

Private _Animal As MyEnum


<Category("My Category"), DefaultValue(GetType(MyEnum), "Dog")> _
Property [Animal]() As MyEnum
Get
Return _Animal
End Get
Set(ByVal Value As MyEnum)
_Animal = Value
End Set
End Property


' ********************
' To grab it after at runtime....

' If Animal = MyEnum.Dog then
'
' End If


End Class


The Grand Master



Thanks that helps a lot. Is there any way to do it as a string
instead of an integer?
 
Ad

Advertisements

M

Master Programmer

If you tried to run my code you stupid ****, then you would see that it
works just fine.

The Grand Master
I don't know how this address the string question, but no Aaron, Strings are
not allowed as enum types. You could, of course, write your own case
statement (if there aren't a lot of Enum choices) to test an Enum value and
assign a different variable according to that Enum value.


Master Programmer said:
Hi Aaron

Try this.....

Public Class MyClass

Public Enum MyEnum
Dog
Cat
Pig
End Enum

Private _Animal As MyEnum


<Category("My Category"), DefaultValue(GetType(MyEnum), "Dog")> _
Property [Animal]() As MyEnum
Get
Return _Animal
End Get
Set(ByVal Value As MyEnum)
_Animal = Value
End Set
End Property


' ********************
' To grab it after at runtime....

' If Animal = MyEnum.Dog then
'
' End If


End Class


The Grand Master



Thanks that helps a lot. Is there any way to do it as a string
instead of an integer?
Public Enum CurrentState
top
middle
bottom
End Enum

Public x As CurrentState
x = (you will get the intellisense dropdown here)


I have been trying to lear vb.net and I cannot remeber how to do
something that I read about a week ago and it is trying me crazy

You now how if you creat a vriable that is boolean whe you type in X
= the tru or false choice comes up. I want to creat a variable that
is a string but can only exsit in three states top middle and bottom.
I forgot how to do it. Sorry for this stupid question
 
S

Stephany Young

Forwarded to (e-mail address removed)


Master Programmer said:
If you tried to run my code you stupid ****, then you would see that it
works just fine.

The Grand Master
I don't know how this address the string question, but no Aaron, Strings
are
not allowed as enum types. You could, of course, write your own case
statement (if there aren't a lot of Enum choices) to test an Enum value
and
assign a different variable according to that Enum value.


Master Programmer said:
Hi Aaron

Try this.....

Public Class MyClass

Public Enum MyEnum
Dog
Cat
Pig
End Enum

Private _Animal As MyEnum


<Category("My Category"), DefaultValue(GetType(MyEnum), "Dog")> _
Property [Animal]() As MyEnum
Get
Return _Animal
End Get
Set(ByVal Value As MyEnum)
_Animal = Value
End Set
End Property


' ********************
' To grab it after at runtime....

' If Animal = MyEnum.Dog then
'
' End If


End Class


The Grand Master



(e-mail address removed) wrote:
Thanks that helps a lot. Is there any way to do it as a string
instead of an integer?
Public Enum CurrentState
top
middle
bottom
End Enum

Public x As CurrentState
x = (you will get the intellisense dropdown here)


I have been trying to lear vb.net and I cannot remeber how to do
something that I read about a week ago and it is trying me crazy

You now how if you creat a vriable that is boolean whe you type in
X
= the tru or false choice comes up. I want to creat a variable
that
is a string but can only exsit in three states top middle and
bottom.
I forgot how to do it. Sorry for this stupid question
 
R

rowe_newsgroups

I guessing here, but maybe you mean you want to return the string value
of an enum item?

Something like:

Public Enum CurrentState
top
middle
bottom
End Enum

Dim x As CurrentState = CurrentState.top
Console.WriteLine(x.ToString()) ' Prints top

Thanks,

Seth Rowe
 
R

RobinS

Oh, I like that. I filled out a report about him on
the Google website, but it doesn't seem to have helped.
Yet.

Robin S.
-------------------------------------
Stephany Young said:
Forwarded to (e-mail address removed)


Master Programmer said:
If you tried to run my code you stupid ****, then you would see that
it
works just fine.

The Grand Master
I don't know how this address the string question, but no Aaron,
Strings are
not allowed as enum types. You could, of course, write your own
case
statement (if there aren't a lot of Enum choices) to test an Enum
value and
assign a different variable according to that Enum value.


Hi Aaron

Try this.....

Public Class MyClass

Public Enum MyEnum
Dog
Cat
Pig
End Enum

Private _Animal As MyEnum


<Category("My Category"), DefaultValue(GetType(MyEnum), "Dog")>
_
Property [Animal]() As MyEnum
Get
Return _Animal
End Get
Set(ByVal Value As MyEnum)
_Animal = Value
End Set
End Property


' ********************
' To grab it after at runtime....

' If Animal = MyEnum.Dog then
'
' End If


End Class


The Grand Master



(e-mail address removed) wrote:
Thanks that helps a lot. Is there any way to do it as a string
instead of an integer?
On Wed, 20 Dec 2006 21:12:23 -0500, "Scott M."
<s-mar@nospam.nospam>
wrote:

Public Enum CurrentState
top
middle
bottom
End Enum

Public x As CurrentState
x = (you will get the intellisense dropdown here)


I have been trying to lear vb.net and I cannot remeber how to
do
something that I read about a week ago and it is trying me
crazy

You now how if you creat a vriable that is boolean whe you
type in X
= the tru or false choice comes up. I want to creat a
variable that
is a string but can only exsit in three states top middle and
bottom.
I forgot how to do it. Sorry for this stupid question
 
M

Master Programmer

I thought you were meant to be the experts. Here it is again.....


Public Class MyClass

Public Enum MyEnum
Top
Middle
Bottom
End Enum

Private _Vertical_Position As MyEnum

<Category("Appearance"), DefaultValue(GetType(MyEnum), "Middle")> _

Property [Vertical_Position]() As MyEnum
Get
Return _Vertical_Position
End Get
Set(ByVal Value As MyEnum)
_Vertical_Position = Value
End Set
End Property


' ********************
' To grab it after at runtime....


' If Vertical_Position = MyEnum.Top then
'
' End If


End Class
 
Ad

Advertisements

C

code_munger

Wow, thanks Master Programmer. Thats just what I have been looking for.
You really are a master.

Thanks Again
Peter


Master said:
I thought you were meant to be the experts. Here it is again.....


Public Class MyClass

Public Enum MyEnum
Top
Middle
Bottom
End Enum

Private _Vertical_Position As MyEnum

<Category("Appearance"), DefaultValue(GetType(MyEnum), "Middle")> _

Property [Vertical_Position]() As MyEnum
Get
Return _Vertical_Position
End Get
Set(ByVal Value As MyEnum)
_Vertical_Position = Value
End Set
End Property


' ********************
' To grab it after at runtime....


' If Vertical_Position = MyEnum.Top then
'
' End If


End Class



Thanks that helps a lot. Is there any way to do it as a string
instead of an integer?
 
H

Henry Jones

What a idiot you are to speak the way you do. Someone who isn't an expert
is asking questions and you stoop so low. I hope you don't have a wife....
If you do she most likely has called or should call the abuse hotline to get
away from someone like you.


Master Programmer said:
If you tried to run my code you stupid ****, then you would see that it
works just fine.

The Grand Master
I don't know how this address the string question, but no Aaron, Strings
are
not allowed as enum types. You could, of course, write your own case
statement (if there aren't a lot of Enum choices) to test an Enum value
and
assign a different variable according to that Enum value.


Master Programmer said:
Hi Aaron

Try this.....

Public Class MyClass

Public Enum MyEnum
Dog
Cat
Pig
End Enum

Private _Animal As MyEnum


<Category("My Category"), DefaultValue(GetType(MyEnum), "Dog")> _
Property [Animal]() As MyEnum
Get
Return _Animal
End Get
Set(ByVal Value As MyEnum)
_Animal = Value
End Set
End Property


' ********************
' To grab it after at runtime....

' If Animal = MyEnum.Dog then
'
' End If


End Class


The Grand Master



(e-mail address removed) wrote:
Thanks that helps a lot. Is there any way to do it as a string
instead of an integer?
Public Enum CurrentState
top
middle
bottom
End Enum

Public x As CurrentState
x = (you will get the intellisense dropdown here)


I have been trying to lear vb.net and I cannot remeber how to do
something that I read about a week ago and it is trying me crazy

You now how if you creat a vriable that is boolean whe you type in
X
= the tru or false choice comes up. I want to creat a variable
that
is a string but can only exsit in three states top middle and
bottom.
I forgot how to do it. Sorry for this stupid question
 
M

Master Programmer

Thanks, but I already know that I am the best and dont need to be told.

The Grand Master

Wow, thanks Master Programmer. Thats just what I have been looking for.
You really are a master.

Thanks Again
Peter


Master said:
I thought you were meant to be the experts. Here it is again.....


Public Class MyClass

Public Enum MyEnum
Top
Middle
Bottom
End Enum

Private _Vertical_Position As MyEnum

<Category("Appearance"), DefaultValue(GetType(MyEnum), "Middle")> _

Property [Vertical_Position]() As MyEnum
Get
Return _Vertical_Position
End Get
Set(ByVal Value As MyEnum)
_Vertical_Position = Value
End Set
End Property


' ********************
' To grab it after at runtime....


' If Vertical_Position = MyEnum.Top then
'
' End If


End Class



Thanks that helps a lot. Is there any way to do it as a string
instead of an integer?
Public Enum CurrentState
top
middle
bottom
End Enum

Public x As CurrentState
x = (you will get the intellisense dropdown here)


I have been trying to lear vb.net and I cannot remeber how to do
something that I read about a week ago and it is trying me crazy

You now how if you creat a vriable that is boolean whe you type in X
= the tru or false choice comes up. I want to creat a variable that
is a string but can only exsit in three states top middle and bottom.
I forgot how to do it. Sorry for this stupid question
 
S

Scott M.

Hoping that you have stopped beating your wife and children long enough to
read this conversation, I'll state that your code does not, in any way,
address the question of having enums stored as strings.

Your code is the same thing that I wrote, but you just added a property to
get and set these enum values somewhere, but your propety is not of the
string type (nor, could it be since the property must be of the same type as
the enum).
 
Ad

Advertisements

S

Scott M.

LOL - Do you know how sick you are to post messages under two different
names and then to carry on a conversation by yourself, patting yourself on
the back?!


Master Programmer said:
Thanks, but I already know that I am the best and dont need to be told.

The Grand Master

Wow, thanks Master Programmer. Thats just what I have been looking for.
You really are a master.

Thanks Again
Peter


Master said:
I thought you were meant to be the experts. Here it is again.....


Public Class MyClass

Public Enum MyEnum
Top
Middle
Bottom
End Enum

Private _Vertical_Position As MyEnum

<Category("Appearance"), DefaultValue(GetType(MyEnum), "Middle")> _

Property [Vertical_Position]() As MyEnum
Get
Return _Vertical_Position
End Get
Set(ByVal Value As MyEnum)
_Vertical_Position = Value
End Set
End Property


' ********************
' To grab it after at runtime....


' If Vertical_Position = MyEnum.Top then
'
' End If


End Class



(e-mail address removed) wrote:
Thanks that helps a lot. Is there any way to do it as a string
instead of an integer?
Public Enum CurrentState
top
middle
bottom
End Enum

Public x As CurrentState
x = (you will get the intellisense dropdown here)


I have been trying to lear vb.net and I cannot remeber how to do
something that I read about a week ago and it is trying me crazy

You now how if you creat a vriable that is boolean whe you type
in X
= the tru or false choice comes up. I want to creat a variable
that
is a string but can only exsit in three states top middle and
bottom.
I forgot how to do it. Sorry for this stupid question
 
M

Master Programmer

Obviously he didnt want it in an "actual string" you ****ing retard. He
wanted it to be human readable - not an integer. To say you are here
trying to show off to these kids, you are not very intelligent.

The Grand Master
 
M

Master Programmer

I am just so pleased I could be of help.

The Grand Master
LOL - Do you know how sick you are to post messages under two different
names and then to carry on a conversation by yourself, patting yourself on
the back?!


Master Programmer said:
Thanks, but I already know that I am the best and dont need to be told.

The Grand Master

Wow, thanks Master Programmer. Thats just what I have been looking for.
You really are a master.

Thanks Again
Peter


Master Programmer wrote:
I thought you were meant to be the experts. Here it is again.....


Public Class MyClass

Public Enum MyEnum
Top
Middle
Bottom
End Enum

Private _Vertical_Position As MyEnum

<Category("Appearance"), DefaultValue(GetType(MyEnum), "Middle")> _

Property [Vertical_Position]() As MyEnum
Get
Return _Vertical_Position
End Get
Set(ByVal Value As MyEnum)
_Vertical_Position = Value
End Set
End Property


' ********************
' To grab it after at runtime....


' If Vertical_Position = MyEnum.Top then
'
' End If


End Class



(e-mail address removed) wrote:
Thanks that helps a lot. Is there any way to do it as a string
instead of an integer?
Public Enum CurrentState
top
middle
bottom
End Enum

Public x As CurrentState
x = (you will get the intellisense dropdown here)


I have been trying to lear vb.net and I cannot remeber how to do
something that I read about a week ago and it is trying me crazy

You now how if you creat a vriable that is boolean whe you type
in X
= the tru or false choice comes up. I want to creat a variable
that
is a string but can only exsit in three states top middle and
bottom.
I forgot how to do it. Sorry for this stupid question
 
Ad

Advertisements

S

Scott M.

Ok Sybil.


Master Programmer said:
I am just so pleased I could be of help.

The Grand Master
LOL - Do you know how sick you are to post messages under two different
names and then to carry on a conversation by yourself, patting yourself
on
the back?!


Master Programmer said:
Thanks, but I already know that I am the best and dont need to be told.

The Grand Master

(e-mail address removed) wrote:
Wow, thanks Master Programmer. Thats just what I have been looking
for.
You really are a master.

Thanks Again
Peter


Master Programmer wrote:
I thought you were meant to be the experts. Here it is again.....


Public Class MyClass

Public Enum MyEnum
Top
Middle
Bottom
End Enum

Private _Vertical_Position As MyEnum

<Category("Appearance"), DefaultValue(GetType(MyEnum),
"Middle")> _

Property [Vertical_Position]() As MyEnum
Get
Return _Vertical_Position
End Get
Set(ByVal Value As MyEnum)
_Vertical_Position = Value
End Set
End Property


' ********************
' To grab it after at runtime....


' If Vertical_Position = MyEnum.Top then
'
' End If


End Class



(e-mail address removed) wrote:
Thanks that helps a lot. Is there any way to do it as a string
instead of an integer?
On Wed, 20 Dec 2006 21:12:23 -0500, "Scott M."
<s-mar@nospam.nospam>
wrote:

Public Enum CurrentState
top
middle
bottom
End Enum

Public x As CurrentState
x = (you will get the intellisense dropdown here)


I have been trying to lear vb.net and I cannot remeber how to do
something that I read about a week ago and it is trying me
crazy

You now how if you creat a vriable that is boolean whe you
type
in X
= the tru or false choice comes up. I want to creat a variable
that
is a string but can only exsit in three states top middle and
bottom.
I forgot how to do it. Sorry for this stupid question
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Newbie Question 2
Newby question 4
Newbie Question 5
Newbie question 1
Newbie question 21
Newbie Questions 1
Newbie Question 3
NEWBIE question 5

Top