["\$ convert.vb~.C\$ ","H&DeXBX|F6A98}(+CCh","Convert String, Integer."," A String can be converted to an Integer. The String stores the digits of a number. Some functions available do not handle invalid cases well. We show the Integer.TryParse method as a solution to this problem. ","Integer ","integer-vbnet","In this program,"," the input String is correctly formatted. It contains the number \"123456\" stored as characters. We declare the local variable i (As Integer) and then use Integer.TryParse in an If-expression. "," .NET 4.7 (2017)\n\n","VB.NET program that converts String to Integer","\n\nModule Module1\n Sub Main()","\n ' Input String.\n ","Dim value As String = ","\"123456\"","\n\n ' Use Integer.TryParse.\n ","Dim i As Integer\n If (","Integer.TryParse","(value, i)) Then\n Console.WriteLine(","\"Integer: {0}\"",", i)\n Console.WriteLine(","\"Half: {0}\"",", i / 2)\n End If\n End Sub\nEnd Module\n\n","\n\nInteger: 123456\nHalf: 61728","In this program,"," after Integer.TryParse returns True, we have an actual Integer. We show this by dividing the Integer by two. This would not be possible with a number stored in String format.","Discussion."," I have often wondered the best way to parse numbers in the .NET Framework. Overall, Integer.TryParse (and its equivalents) is what I feel is the best solution. It does not cause performance problems when an invalid number is encountered. ","You do not have to write custom algorithms. TryParse will tell you if you have an invalid number.","Therefore: ","Integer.TryParse is probably best unless you have serious performance demands.","Summary."," We converted a String holding digit characters into an actual Integer in the VB.NET language. There are many parsing functions available in the .NET Framework, but Integer.TryParse (and other TryParse functions) is versatile and useful."]