|
-
Jul 29th, 2004, 02:36 PM
#1
which one to use?
I am doing some form validation and I simply want to check if a given text box was filled in.. doesnt matter with what.
simple enough, I know... but which one of these methods for doing so would you say is the best. or is it all just preference?
VB Code:
txtName1.Text = String.Empty
txtName1.Text.Length = 0
Len(txtName1.Text) = 0
txtName1.Text = ""
txtName1.Text.Equals(String.Empty)
-
Jul 29th, 2004, 02:53 PM
#2
I would say
if txtName1.Text.Length = 0 then...
is best because it's just fetching a property that is already known, rather than some of your other suggestions that have to do extra string comparison processing.
$0.02
I don't live here any more.
-
Jul 29th, 2004, 03:20 PM
#3
Originally posted by wossname
I would say
if txtName1.Text.Length = 0 then...
is best because it's just fetching a property that is already known, rather than some of your other suggestions that have to do extra string comparison processing.
$0.02
valid point. Although who knows what the code looks like in the get of the Length property... could be more (or just as) cumbersome than one of the other methods.. but to be honest, I guess all would be just fine..
I guess am just trying to find the one I wont get laughed at for when a better coder looks at and says "what in the hell are you doing it this way for"
-
Jul 29th, 2004, 03:38 PM
#4
Fanatic Member
i usually just do
= "" I learnt it that way from vb6 tho so i haven't changed. See no reason to, it does exactly the same.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|