Solved

Type 'Item' is not defined vb.net

Posted on 2015-01-11
1
248 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
1 Comment
 
LVL 62

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now