Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem checking for double 2

Status
Not open for further replies.

DotNetBlocks

Programmer
Apr 29, 2004
161
US
Hello All,
I am having a problem. I have a textbox with a value that is a double "12.90", how can i check to make sure the type is double. I want to send a message if it is not.

Thanks,
babloome
 
I'm not sure if there is an IsDecimal funtion, but this should attempt to cast the string to decimal:
Code:
try
  dim dTest as decimal = cdec(textbox1.text)
catch 
  messagebox.show("Please enter a decimal in text box 1.")
end try

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Yes but I wouldn't do the me.text = "Enter a double you fool!!" since this could get you into an endless loop because the textbox will only accept doubles. And most user would just try entering "a double you fool!!" wich would give you even more work.


Christiaan Baes
Belgium

"My new site" - Me
 
Thanks for the help everyone, I will try the example now.

Babloome
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top