View Single Post
 
Old October 30th, 2012, 10:15 AM
Rod Stephens's Avatar
Rod Stephens Rod Stephens is offline
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

Quote:
//check if textbox is empty
if (tbxLengthToConvert == null)
What this is really doing is comparing the TextBox itself to null. The TextBox exists so it isn't null and this will never be true.

Instead you need to compare the Text inside the TextBox. And don't compare it to null because blank isn't the same as null. For example, try:

Code:
if (tbxLengthToConvert.Text == "")
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)