Common Function to Check the TextBox is blank or not


Common Function to Check the TextBox is blank or not

Parameter : Textbox, & TextBox Description
Output : Returns False, Popup the Message like "Name Can Not Be Blank."

Code :

 
Shared Function ChkBlank(ByVal CTxt As TextBox, ByVal CTxtNam As String) As Boolean
If Len(CTxt.Text.Trim()) > 0 Then
Return True
Else
MessageBox.Show(CTxtNam & " Can Not Be Blank", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Warning)
CTxt.Focus()
Return False
End If
End Function


Comments

Author: Sreenivasulu Reddy03 Mar 2010 Member Level: Silver   Points : 1

c#
---

public bool checknull()
{
if(TextBox1.Text=="")
{
return true;
}
else
{
return false;
}
}
call this function where ever you want.

Author: Prasanti Prusty04 Mar 2010 Member Level: Silver   Points : 1

The above code is to Display a message as well as it'll give focus on the text box if it is blank.

Thanks.
Regards,
Prasanti



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: