Solved

Type 'Item' is not defined vb.net

Posted on 2015-01-11
1
286 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

707 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