.net - VB.NET: Input string was not in a correct format -


with following snippet

foo = iif(string.isnullorempty(txtfoo.text), 0, integer.parse(txtfoo.text.trim)) 

i error when submit field without value: "input string not in correct format." don't have space or else , string.isnullorempty(txtfoo.text) returns true. wrong? thank you.

iif evaluate:

integer.parse(txtfoo.text.trim)  

irrespective of whether:

string.isnullorempty(txtfoo.text)  

is true or not (as function 3 arguments passed it, arguments must valid). if txtfoo.text empty, it's still trying parse integer in case.

if you're using vs2008, can use if operator instead short-circuit you're expecting iif do.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -