This tutorial is all about How to Validate Double Value in VB.Net. With this tutorial you can Validate Double Value in VB.Net easily. So let’s get started:
- First is open the Visual Basic, Select File on the menu, then click New and create a new project.
- Then a New Project Dialog will appear. You can rename your project, depending on what you like to name it. After that click OK
- Design your form like this just like what I’ve shown you below.
Add a Label, Button and Textbox.
- Add this following function.
Function validateDoublesAndCurrency(ByVal stringValue As String) As Boolean
Dim rslt As Boolean = False
Dim value As Double
Dim valueToTest As String = stringValue
TryvalueToTest = Double.Parse(stringValue, Globalization.NumberStyles.Currency)
Catch ex As ExceptionEnd Try
If Double.TryParse(valueToTest, value) Then
rslt = True
rslt = False
- Then add this code to the button.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If validateDoublesAndCurrency(TextBox1.Text) = False Then
MsgBox(“Price entered is not valid”)
MsgBox(“Price is Valid”)
- Finally, Click F5 to run.
If you have any comments or suggestion about on How to Validate Double Value in VB.Net, Please Feel Free to contact our webpage.
Download How to Validate Double Value in VB.Net Code Here
Other articles you might read also:
- Regular Expressions
- How to Reorder List in Listbox using VB.Net
- Get List of Installed Fonts Using ListBox in VB.Net