Ch 3 Type Conversion Yonglei Tao
Method TryParse() Convert a string to a numeric data type Dim sales As Decimal Decimal.TryParse ( txtSales.Text, sales ) Dim num As Integer Integer.TryParse ( txtNumber.Text, num )
Examples
Class Convert Provides methods to convert a value from one data type to another Dim rate As Double = 0.05 tax = Convert.ToDecimal ( rate ) * total lblAverage.Text = Convert.ToString ( avgScore )
Method ToString() Available to each variable of a numeric type
Option Explicit/Strict