CheckingInputTextBoxes

=__**Checking For Input in Text Boxes**__=


 * When using textboxes we usually check that the user has actually entered something in our textbox by using code such as ;

 Dim name as String name = txtSearch.text

 If name = "" then  messagebox.show("Please type something in the textbox!!!")  exit sub

The only problem with this is that if the user adds spaces into the textbox with no text, Visual Studio will still class the spaces as characters and there for the code will still go ahead and the messagebox will not show.

I have found a String method called Trim which can be used to take away the leading and trailing spaces in the String and solve the above problem. There are two ways you can use this method.

1) 

Dim name as String name = Trim ( txtSearch.text)

  I f name = "" then  messagebox.show     **    **<span style="color: rgb(20, 74, 240)">("Please type something in the textbox!!!")  **    **   <span style="color: rgb(5, 14, 199)"><span style="color: rgb(34, 23, 232)"><span style="color: rgb(27, 18, 237)"><span style="color: rgb(0, 0, 0)"><span style="color: rgb(29, 89, 237); text-align: left; display: block">exit sub

2)** <span style="color: rgb(21, 99, 239)">

name = txtSearch.text name = name<span style="color: rgb(240, 51, 51)">. <span style="color: rgb(234, 46, 46)">Trim **
 * Dim name as String

<span style="color: rgb(20, 84, 230)"><span style="color: rgb(0, 0, 0)">**<span style="color: rgb(27, 99, 238)"> If name = "" then <span style="color: rgb(19, 95, 241)"> messagebox.show **  **<span style="color: rgb(0, 0, 0)"><span style="color: rgb(20, 74, 240)">("Please type something in the textbox!!!")  **<span style="color: rgb(21, 99, 239)"><span style="color: rgb(20, 84, 230)"><span style="color: rgb(0, 0, 0)"><span style="color: rgb(19, 95, 241)"> <span style="color: rgb(42, 109, 239)"> **exit sub**   <span style="color: rgb(20, 84, 230)">