Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 2 - Types of Operators in Visual Basic
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

Types of Operators in Visual Basic
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 5
    2007-09-13

    Table of Contents:
  • Types of Operators in Visual Basic
  • The Like Operator
  • Operator Overloading
  • Operator Precedence

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Types of Operators in Visual Basic - The Like Operator
    (Page 2 of 4 )

    The Like operator is used to match a string against a pattern. It compares a string expression or literal with a string pattern expression and determines whether they match (the result is True) or not (the result is False). For example:

      If (testString Like "[A-Z]#") Then

    matches a capital letter followed by a digit.

    For details on the use of this operator, including special characters used in the pattern string, see the "Like Operator" entry in Chapter 12.

    Object Operators

    Visual Basic includes five operators that return results based on an operand's object properties.

    Is

    The Is operator determines whether two object reference variables refer to the same object instance.

      result = object1 Is object2

    If both object1 and object2  refer to the same object instance, the result is True; otherwise, the result is False. You can also use the Is operator to determine if an object variable refers to a valid object. This is done by comparing the object variable to the Nothing keyword:

      If (customerRecord Is Nothing) Then

    The result is True if the object variable does not hold a reference to any object.

    IsNot

    New in 2005. The IsNot operator is equivalent to the Is operator used with the Not logical operator. The statement:

      If (customerRecord IsNot Nothing) Then

    is the same as:

      If Not (customerRecord Is Nothing) Then

    There is no functional difference between the two statements. The IsNot operator was added to VB to make such statements more readable.

    TypeOf

    The TypeOf operator determines if an object variable is of a specific data type. It is always used with the Is operator. (It does not work with the new VB 2005 IsNot operator.) The following statement tests an object variable to see if it is an Integer.

      If (TypeOf someNumber Is Integer) Then

    AddressOf

    The AddressOf operator returns a procedure delegate that can be used to reference a procedure through a variable. In VB 6, the AddressOf operator returned a function pointer, the memory address of the function. While the .NET version of this operator serves a similar purpose, it does not return a memory address. The .NET Framework reserves the right to move objects (including procedures) to new memory locations at any time, so you cannot depend on the memory address.

    For details on the AddressOf operator, including usage information, see the AddressOf Operator entry in Chapter 12.

    GetType

    The GetType operator returns a System.Type object that contains information about the data type of the operand. You cannot use expressions or variables as operands; you must pass a data type itself. You can use VB data types (like Integer or String), .NET core types (like System.Int32), or the name of any class, structure, or similar construct. For example:

      result = GetType(Integer)

    returns a System.Type object that provides information about the System.Int32 data type, which is the true data type of the Visual Basic Integer data type.

    More Visual Basic.NET Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Visual Basic 2005 in a Nutshell, Third...
     

    Buy this book now. This article is excerpted from chapter five of the book Visual Basic 2005 in a Nutshell, Third Edition, written by Tim Patrick, Steven Roman, Ph.D., Ron Petrusha and Paul Lomax (O'Reilly; ISBN: 059610152X). Check it out today at your favorite bookstore. Buy this book now.

    VISUAL BASIC.NET ARTICLES

    - Types of Operators in Visual Basic
    - Operators
    - Understanding Custom Events using Visual Bas...
    - Polymorphism using Abstract Classes in Visua...
    - Shadowing using Shadows in Visual Basic.NET ...
    - Overloading and Overriding in Visual Basic.N...
    - More on Controlling Windows Fax Services Usi...
    - Programmatically Controlling Windows Fax Ser...
    - Focusing on Forms and Menus in Visual Basic
    - Manipulating Forms with the Windows Forms Li...
    - Basics of the Windows Forms Library
    - Forms, Controls, and Other Useful Objects
    - Implementing OOP to Develop Database Oriente...
    - Using Themes and Skins for Personalization w...
    - A Deeper Look at Personalization using Visua...




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway