vb.net - How to exempt a textbox from being field -


i working on project using vb.net , have 4 text boxes , 2 tabpages on form. wrote program in such way 4 text boxes must filled before can go tabpage2.

here problem. need textbox1 empty , still able go tabpage2 when textbox2, 3 , 4 must filled

here code

private sub tabcontrol1_selecting(byval sender object, byval e system.windows.forms.tabcontrolcanceleventargs) handles tabcontrol1.selecting    each textbox control in me.controls         if typeof textbox textbox             if textbox.text.equals(string.empty)                 if e.tabpage tabpage2                     msgbox("fill textbox")                     e.cancel = true                 end if             end if         end if     next 

well, add and textbox.name <> textbox1.name conditional check.

private sub tabcontrol1_selecting(byval sender object, byval e system.windows.forms.tabcontrolcanceleventargs) handles tabcontrol1.selecting    each textbox control in me.controls         if typeof textbox textbox             if textbox.text.equals(string.empty) , textbox.name <> textbox1.name                 if e.tabpage tabpage2                     msgbox("fill textbox")                     e.cancel = true                 end if             end if         end if     next 

by way, can shorten code directly declaring textbox textbox, , not control:

    private sub tabcontrol1_selecting(byval sender object, byval e system.windows.forms.tabcontrolcanceleventargs) handles tabcontrol1.selecting    each textbox textbox in me.controls.oftype(of textbox)()              if textbox.text.equals(string.empty) , textbox.name <> textbox1.name                 if e.tabpage tabpage2                     msgbox("fill textbox")                     e.cancel = true                 end if          end if     next 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -