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.
Open Microsoft Visual Studio 2015 and create a new windows form application for visual basic.
Do the form just like shown below.
Double click the button and do the following codes to convert the string to decimal when the button is clicked.
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- Dim strNumber As String = TextBox1.Text
- Dim dcmNumbers As Decimal
- dcmNumbers = strNumber
- If dcmNumbers >= 0 Then
- TextBox2.Text = dcmNumbers .ToString("##,###.00")
- dcmNumbers = Math.Abs(dcmNumbers )
- TextBox2.Text = dcmNumbers .ToString("##,###.00") & "-"
- End If
- End Sub
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.