Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VB.Net .Clear() or txtbox.Text = "" textbox clear methods

Not far into programming and just joined this forum of mighty company so this is a silly question, but what is the best way to clear textboxes in VB.Net and what is the difference between the two methods? I have also seen people be critical of folk using clear objects on their forms and I can see why but in this case, I am only learning.

txtbox1.Clear()

or

txtbox1.Text = ""

Any help is much appreciated.

like image 864
William Mc Avatar asked Sep 20 '10 18:09

William Mc


1 Answers

The two methods are 100% equivalent.

I’m not sure why Microsoft felt the need to include this extra Clear method but since it’s there, I recommend using it, as it clearly expresses its purpose.

like image 169
Konrad Rudolph Avatar answered Sep 19 '22 12:09

Konrad Rudolph