P. 1
Vbnet Notes

Vbnet Notes

|Views: 46|Likes:
Published by nanobala15

More info:

Published by: nanobala15 on Aug 13, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

10/25/2012

pdf

text

original

When types cannot be implicitly converted you should convert them explicitly. This
conversion is also called as cast. Explicit conversions are accomplished using CType
function.

CType function for conversion

If we are not sure of the name of a particular conversion function then we can use
the CType function. The above example with a CType function looks like this:

Imports System.Console
Module Module1

Sub Main()
Dim d As Double
d = 132.31223
Dim i As Integer
i = CType(d, i)
'two arguments, type we are converting from, to type desired
WriteLine("Integer value is" & i)
End Sub

End Module

Below is the list of conversion functions which we can use in VB .NET.

CBool

- use this function to convert to Bool data type

CByte

- use this function to convert to Byte data type

CChar

- use this function to convert to Char data type

CDate

- use this function to convert to Date type
CDbl - use this function to convert to Double data type
CDec - use this function to convert to Decimal data type
CInt - use this function to convert to Integer data type
CLng

- use this function to convert to Long data type

CObj

- use this function to convert to Object type
CShort - use this function to convert to Short data type
CSng

- use this function to convert to Single data type
CString - use this function to convert to String data type

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->