Convert single value to decimal : Convert « Development « VB.Net






Convert single value to decimal

  

Module Example
   Public Sub Main()
        Dim numbers() As Single = { Single.MinValue, -3e10, -1093.54, 0, 1e-03, _
                                    1034.23, Single.MaxValue }
        Dim result As Decimal
        
        For Each number As Single In numbers
           Try
              result = Convert.ToDecimal(number)
              Console.WriteLine("Converted the Single value {0} to {1}.", number, result)
           Catch e As OverflowException
              Console.WriteLine("{0} is out of range of the Decimal type.", number)
           End Try
        Next                                  
   End Sub
End Module

   
    
  








Related examples in the same category

1.Convert.ChangeType
2.Convert numeric string to SByte without a format provider
3.Convert numeric string to SByte with a format provider.
4.Converting strings to numbers in base
5.Convert.ToBase64CharArray converts 8-bit unsigned integer array to Unicode character array
6.Convert the Char array back to a Byte array
7.Convert.ToBase64String converts 8-bit unsigned integers to string encoded with base-64 digits.
8.Convert string by different base
9.Convert.ToDateTime (Object) converts object to a DateTime object.
10.Convert.ToDateTime Method (Object, IFormatProvider) converts object to DateTime using culture-specific format
11.Convert.ToDateTime(String) converts string to date and time value.
12.Convert.ToDateTime(String, IFormatProvider) converts string to date and time, using culture-specific format
13.Convert hex string to Int16
14.Convert hex string to int64
15.Convert Long to Integer
16.Convert double to Integer
17.Convert BigInteger to Integer
18.Convert decimal to Integer