Posted by: Sourav | August 26, 2016

Enum example in VB,VB Teacher Sourav,Kolkata 09748184075

Option Strict On
Option Explicit On
Imports System

Module Module1

Sub Main()
Dim customers(3) As customer
customers(0) = New customer
customers(0).manipulatename = “Sourav”
customers(0).manipulategender = gender.Male

customers(1) = New customer
customers(1).manipulatename = “Sougata”
customers(1).manipulategender = gender.Female

customers(2) = New customer
customers(2).manipulatename = “Subrata”
customers(2).manipulategender = gender.unknown

For Each customer As customer In customers
If IsNothing(customer) <> True Then
Console.WriteLine(“The name is {0} “, customer.manipulatename)
Console.WriteLine(“The gender is {0} “, getgender(customer.manipulategender))
End If


End Sub

Public Function getgender(ByVal gender As gender) As String
Select Case gender

Case gender.unknown
Return “Unknown”
Case gender.Male
Return “Male”
Case gender.Female
Return “Female”
Case Else
Return “Invalid date selected”
End Select

End Function
End Module
Public Class customer
Private name As String
Public Property manipulatename() As String

End Get
Set(ByVal value As String) = value
End Set
End Property
Private gender As Integer
Public Property manipulategender() As gender

Return CType(Me.gender, enumvb.gender)
End Get
Set(ByVal value As gender)
Me.gender = value
End Set
End Property

End Class
Public Enum gender
End Enum


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: