Skip to Content
VB .NET Language in a Nutshell
book

VB .NET Language in a Nutshell

by Steven Roman PhD, Ron Petrusha, Paul Lomax
August 2001
Intermediate to advanced
656 pages
18h 5m
English
O'Reilly Media, Inc.
Content preview from VB .NET Language in a Nutshell

Name

CType Function

Named Arguments

No

Syntax

CType(expression, typename)
expression

Use: Required

Data Type: Any

The data item to be converted

typename

Use: Required

Type: Keyword

The data type, object type, structure, or interface to which expression is to be converted

Return Value

expression cast as a typename interface, object, structure, or data type.

Description

Converts any expression that can be interpreted as an object to Object.

Rules at a Glance

  • expression can be any data, object, structure, or interface type.

  • typename can be any data type (such as Boolean, Byte, Decimal, Long, Short, String, etc.), structure type, object type, or interface that can be used with the As clause in a Dim statement.

  • If the function fails, or if the converted value of expression is outside the range allowed by typename, an InvalidCastException exception occurs.

Example

Option Strict On Imports Microsoft.VisualBasic Imports System Interface IEmployee Property Name( ) As String Property Salary( ) As Decimal End Interface Public Class CSalaried Implements IEmployee Dim sName As String Dim decSalary AS DEcimal Public Property Name( ) As String Implements IEmployee.Name Get Name = sName End Get Set sName = Value End Set End Property Public Property Salary( ) As Decimal Implements IEmployee.Salary Get Salary = decSalary End Get Set decSalary = Value End Set End Property End Class Module modMain Public Sub Main( ) Dim oSal As New CSalaried Dim oSal2 As CSalaried Dim oEmp As IEmployee oSal.Name = "John Doe" ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

VB & VBA in a Nutshell: The Language

VB & VBA in a Nutshell: The Language

Paul Lomax
VB.NET Language in a Nutshell, Second Edition

VB.NET Language in a Nutshell, Second Edition

Steven Roman PhD, Ron Petrusha, Paul Lomax

Publisher Resources

ISBN: 0596000928Catalog PageErrata