Easiest Way to Convert String to Decimal in VB.Net

Submitted by: 
Visitors have accessed this post 206 times.

In this tutorial, I will teach you how to convert string to decimal in vb.net. This simple program will help you turn the whole number into decimal separated by commas in the easiest way. See the procedure below to find out what the process would be.

Creating Application

Step 1

Open Microsoft Visual Studio 2015 and create a new windows form application for visual basic.
ps1

Step 2

Do the form just like shown below.
ps2

Step 3

Double click the button and do the following codes to convert the string to decimal when the button is clicked.

  1. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  2. Dim strNumber As String = TextBox1.Text
  3. Dim dcmNumbers As Decimal
  4. dcmNumbers = strNumber
  5.  
  6. If dcmNumbers >= 0 Then
  7. TextBox2.Text = dcmNumbers .ToString("##,###.00")
  8. Else
  9. dcmNumbers = Math.Abs(dcmNumbers )
  10. TextBox2.Text = dcmNumbers .ToString("##,###.00") & "-"
  11. End If
  12. End Sub

Output.
ps3
For any questions about this article. You can contact me @
Email – [email protected]
Mobile No. – 09305235027 – TNT
Or feel free to comment below.


Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.