Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms


.

Home to new Visual Basic .NET programmers

Constants & Enumerators

 

Home ] What is this site? ] myExercises ] myTutorials ] myExam ] myMicrosoft ] myNotes ] Study Advice ] myLinks ]


Search (my)Visual Basic .NET

(Tip: Scroll past sponsored links to see your search results for this website)


Complain to Volkswagen South Africa (VWSA)


New to myExercises:

 

Lynnwood Consultants Program
Computer Calculator Program
Funny Time Program
Creative Minds Login Program
Hatfield Pizza & Pasta Program
  Shutterbug Program

New to myNotes:

 

>>

TOE chart


Order this book today from

kalahari.net: click-click, ding-dong

 

Title: Microsoft Visual Basic 2005:

         RELOADED, Second Edition

Author:  Diane Zak

 

Click the image below to order your copy.

 

Up ] GUI Standards ] Access Files ] Accumulators, Counters & Averages ] Arrays ] Collections ] Constants & Enumerators ] Crystal Reports ] Data Types ] Flowchart Symbols ] Functions ] Keywords ] Methods ] Operators ] Repetition Structures ] Selection Structures ] Sub Procedures ] Toolbox Controls ] Variables ] Windows Forms ]


 

Introduction

Constant types

    Intrinsic

        NaN (not a number)

        Infinity

    Literal

    Named

Enumerations (Enum)

purpose

declarations

scope

 


 

Introduction

 

Constants are memory placeholders for data that do not change while your program is running.  A meaningful name is given to a constant - this is simply to make your code easier to read.  The first day of the week is Monday; Monday is a constant, because it never changes and the word Monday is meaningful because you know it refers to the first day of the week.

 

Visual Basic offers its own set of constants, referred to as intrinsic constants.  Data types, like String, Boolean, Single, etc. are intrinsic constants, as well as vbNewLine, among others.  Intrinsic means built-in or native.  In addition to this you the programmer can create your own constants, which are known as named constants and literal constants.  

 

A named constant is a memory location in the computer's memory.  The data contained in it cannot change while the program is running.  Once you create a named constant you use its name rather than its value in your code.  Again, this makes your code easier to read and understand.  Named constants are declared, just like variables, but with a prefix of con, e.g. Const conMessage As String = "Good job!".  When declaring a constant, you must assign it a value.

 

Literal constants are actual items of data, unlike variables that are memory placeholders for data.  Note that you can store a literal constant in a variable and this is done during Design Mode in Visual Basic and not during Runtime.  When you declare a variable, e.g. Dim strName As String, you can store a literal constant in the strName variable during declaration, e.g. Dim strName As String = "Mary".  When you assign a numerical literal constant, you would not use the quotation marks, or else Visual Basic will regard it a string, e.g. intNumber = 500 and not intNumber = "500".

 

Enumerations or Enum is a collective name for a set of values, e.g. the days of the week can be considered as constants and a collective name can be given for them, e.g. DaysOfWeek.  DaysOfWeek will then be regarded an enumeration.

 

    

Constant Types

Intrinsic
NaN (not a number)
NaN is the result of attempting to divide zero by zero.  

 

 

 

 

    Literal

 

 

 

 

 

    Named

 

 

 

 

 

Enumeration (Enum)

    Intrinsic Enumerations

 

    AppWinStyle

    CallType

    CompareMethod

    DateFormat

    FileAttribute

    FirstDayOfWeek

    FirstWeekOfYear

    MsgBoxResult

    MsgBoxStyle

    Tristate

    VbStrConv

 

 

 

 

 


All content on this site is free for private use only  |  Contributions are encouraged  |  Thank you to Netfirms for the free hosting  |  If copyright content is published here or links to certain content violates some right/law, contact the Webmaster to have it removed immediately.

 

Site launched: October 2005  |  Updated: July 20, 2006  |  Link exchange  |  Site map  |  Contact us