Question about CType()

+1 Austin Elliott · June 14, 2014
In this tutorial: you are taught how to convert variables to other types of variables, but I don't understand why, or what the point of the "rawVariable" is.

Please help.

Post a Reply


Oldest  Newest  Rating
0 Justin Hamilton · July 22, 2014
I'd say the biggest use for CType for me is when using streamreader.

When you read lines, you are getting Strings but within those lines you may find numbers too. 
These numbers may need to be added or subtracted or perhaps sorted.

line = sr.readline
delimiter = line.split("_"c) ' Underscore cast into char
if delim(1).Length =4 AndAlso delim(2).IndexOf("CI")>-1 then

chan = CInt(delim(2).SubString(2)) ' Cast String into Integer to evaluate

If chan <10 then
'Do stuff to chan

result = chan.ToString.PadLeft(3,"0") ' Cast Int into String with a Padleft of 3

  • 1

Visual Basic


One of the first products to provide a graphical environment and a paint metaphor for developing user interfaces.

Bucky Roberts Administrator