Solved

Type 'Item' is not defined vb.net

Posted on 2015-01-11
1
269 Views
Last Modified: 2015-01-11
I am testing the following example at: http://www.dotnetperls.com/enum-vbnet but apparently this example is wrong. The bold portion shows "Type 'Item' is not defined".

Dim v As Item = New Item

Question: How can I change this example to make it work?

Example title: Default

Default operator
An Enum has a default value. This corresponds to the value that equals 0 within the Enum type, which is by default the first listed one. When part of a class, an Enum does not need initialization to this default value.

The default values of an enum proceed up from 0.
So the first is zero,
the second is one,
and the third is two. Initializing an Enum to zero is a performance negative. It will result in additional yet unneeded steps.

VB.NET program that uses Enum, default value

Module Module1

    Enum Level
	Normal
	Low
	High
    End Enum

    Class Item
	''' <summary>
	''' Public enum.
	''' </summary>
	Public _level As Level
    End Class

    Sub Main()
	' The default value for an enum is the one equal to 0.
	Dim v As Item = New Item
	Console.WriteLine(v._level.ToString())
    End Sub

End Module

Output

Normal

Open in new window

0
Comment
Question by:Mike Eghtebas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 40543084
Hi eghtebas;

I loaded your code into a project and got the expected results as can be seen in the screen print. I did not get any exception as you did. What line in the code are you getting the exception on?

Results of program execution.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question