Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Type 'Item' is not defined vb.net

Posted on 2015-01-11
1
Medium Priority
?
309 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 64

Accepted Solution

by:
Fernando Soto earned 2000 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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

636 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