Validation using TryParse

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2008
Posts: 23
Reputation: 3Dees is an unknown quantity at this point 
Solved Threads: 0
3Dees 3Dees is offline Offline
Newbie Poster

Validation using TryParse

 
0
  #1
Oct 20th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2002
Posts: 461
Reputation: waynespangler is on a distinguished road 
Solved Threads: 56
waynespangler waynespangler is offline Offline
Posting Pro in Training

Re: Validation using TryParse

 
0
  #2
Oct 20th, 2008
A double can be a 1 or a 1.2 or a .0034567. Just convert the entered number to a double.
Wayne

It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC