ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.VB.Net Integer.TryParse Error: Input string was not in a correct format<p>Hi</p> <p>Will you please let me know what exact result you want to get from the number&nbsp;05-07152.</p>https://www.aspforums.net:443/Threads/161216/VBNet-IntegerTryParse-Error-Input-string-was-not-in-a-correct-format/https://www.aspforums.net:443/Threads/161216/VBNet-IntegerTryParse-Error-Input-string-was-not-in-a-correct-format/Fri, 07 Dec 2018 06:26:42 GMTVB.Net Integer.TryParse Error: Input string was not in a correct format<p>I wanted to retain that very number as it is&nbsp; after requesting it&nbsp;</p>https://www.aspforums.net:443/Threads/161216/VBNet-IntegerTryParse-Error-Input-string-was-not-in-a-correct-format/https://www.aspforums.net:443/Threads/161216/VBNet-IntegerTryParse-Error-Input-string-was-not-in-a-correct-format/Fri, 07 Dec 2018 06:33:39 GMTVB.Net Integer.TryParse Error: Input string was not in a correct format<p>Hi&nbsp;makumbi,</p> <p>You can't convert the number with special character to integer using&nbsp;Integer.TryParse is not possible.</p> <p>You can handle the error using the below way.</p> <p><strong><span style="text-decoration: underline;">C#</span></strong></p> <pre class="brush: csharp">int customerId = 0; string value = &#34;05-07152&#34;; bool success = int.TryParse(value, out customerId); if (success) { Response.Write(String.Format(&#34;Converted &lt;b&gt;{0}&lt;/b&gt; to &lt;b&gt;{1}&lt;/b&gt;.&#34;, value, customerId)); } else { Response.Write(String.Format(&#34;Conversion of &lt;b&gt;{0}&lt;/b&gt; to int failed.&#34;, value)); }</pre> <p><span style="text-decoration: underline;"><strong>VB.Net</strong></span></p> <pre class="brush: vb">Dim customerId As Integer = 0 Dim value As String = &#34;05-07152&#34; Dim success As Boolean = Integer.TryParse(value, customerId) If success Then Response.Write(String.Format(&#34;Converted &lt;b&gt;{0}&lt;/b&gt; to &lt;b&gt;{1}&lt;/b&gt;.&#34;, value, customerId)) Else Response.Write(String.Format(&#34;Conversion of &lt;b&gt;{0}&lt;/b&gt; to int failed.&#34;, value)) End If</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/161216/VBNet-IntegerTryParse-Error-Input-string-was-not-in-a-correct-format/https://www.aspforums.net:443/Threads/161216/VBNet-IntegerTryParse-Error-Input-string-was-not-in-a-correct-format/Fri, 07 Dec 2018 06:52:30 GMT