.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Collections >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Check enum value Defined

Posted By:Narayanan       Posted Date: April 25, 2013    Points: 40    Category: Collections    URL: http://www.dotnetspark.com  

Today ,we will discuss about How to Check enum value defined or not in VB.Net.
 

First Create Enum in your Example and Call Enum.IsDefined method for checking enum value.

Create Enum in Vb.net

 
  Public Enum Sex
        Male
        Female
    End Enum


How to Check enum Value ?

Code:1 
 If [Enum].IsDefined(GetType(Sex), "Male") Then
                MessageBox.Show("")
            End If

Code:2 
 If [Enum].IsDefined(GetType(Sex), "male") Then
                MessageBox.Show("")
            End If

Output:
Code 1:  Message Box will show.
Code 2:  Message Box will not show.


Happy Coding!
Today's Quota: Remember that time is money.

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend