• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 311
  • Last Modified:

Type 'Item' is not defined vb.net

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
Mike Eghtebas
Asked:
Mike Eghtebas
1 Solution
 
Fernando SotoCommented:
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Tackle projects and never again get stuck behind a technical roadblock.
Join Now