954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Validation using TryParse

Hej,
Hope someone can help me with this. Is there a Widows form method equivalent to console.readline? I am trying to validate and input using tryParse to ensure a doulbe is inputted if not display a error message. I got that to work eg when i input an A . But i don't want to continue unless a double is inputted. This is my code i tried but i am missing something:

Public Function IsDouble() As Boolean
IsDouble = True
Dim vDouble As Double

'Function required to validate input
If Not Double.TryParse(txtbox1.Text, vDouble) Then '
MessageBox.Show("enter a double please!")
txtValue.Clear()

Return IsDouble
End If
End Function

3Dees
Newbie Poster
23 posts since Sep 2008
Reputation Points: 10
Solved Threads: 0
 

A double can be a 1 or a 1.2 or a .0034567. Just convert the entered number to a double.

waynespangler
Posting Pro in Training
461 posts since Dec 2002
Reputation Points: 84
Solved Threads: 58
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You