Int32.Parse Method (String, NumberStyles) Converts string to 32-bit signed integer equivalent. : Integer « Data Types « VB.Net






Int32.Parse Method (String, NumberStyles) Converts string to 32-bit signed integer equivalent.

 

Imports System.Globalization

Module ParseInt32
   Public Sub Main()
      Convert("999.9", NumberStyles.AllowDecimalPoint)
      Convert(" $1,999,999.42", NumberStyles.AllowCurrencySymbol Or NumberStyles.Number)
      Convert("999E06", NumberStyles.AllowExponent)  
      Convert("-1,999,999", NumberStyles.AllowThousands)
      Convert("(1,999,999)", NumberStyles.AllowThousands Or NumberStyles.AllowParentheses)
   End Sub

   Private Sub Convert(value As String, style As NumberStyles)
      Try
         Dim number As Integer = Int32.Parse(value, style)
         Console.WriteLine("Converted '{0}' to {1}.", value, number)
      Catch e As FormatException
         Console.WriteLine("Unable to convert '{0}'.", value)
      Catch e As OverflowException
         Console.WriteLine("'{0}' is out of range of the Int32 type.", value)   
      End Try
   End Sub
End Module

   
  








Related examples in the same category

1.Compare Integer value and output their relationCompare Integer value and output their relation
2.Integer Initialize and assignmentInteger Initialize and assignment
3.Integer calculationInteger calculation
4.Define and use Array IntegerDefine and use Array Integer
5.And, Or, Xor and Not on Integer And, Or, Xor and Not on Integer
6.Integer Value DemoInteger Value Demo
7.Integer: add, subtract, multiply and divideInteger: add, subtract, multiply and divide
8.Concatenate string and intConcatenate string and int
9.Append Integer data type values to a StringBuilder object.
10.Generic and nongeneric versions of the CompareTo method for Int16 value
11.Generic and nongeneric versions of the CompareTo method for Int32 value
12.Generic and nongeneric versions of the CompareTo method for Int64 value
13.Use the Sign(Integer) method to determine the sign of an Integer value and display it to the console.
14.Byte Structure Represents an 8-bit unsigned integer.
15.Convert Integer to Byte with CByte
16.Convert Integer to Byte with Convert
17.Parse a negative integer value
18.Int32 Structure Represents a 32-bit signed integer.
19.Integer variables
20.Int32 CompareTo Method
21.Int32 Equals Method
22.Int32.MaxValue Field Represents the largest possible value of an Int32. This field is constant.
23.Int32.Parse Method Converts string to 32-bit signed integer equivalent.
24.Int32 Structure Represents a 32-bit signed integer.