Question: must stop the user from proceeding if the textbox is null, 

if the textbox has only spaces in it.

i tried . trim but that doesnot work, still spaces are excapted as valid characters.

Answer: 
If you are using .NET 4 - [String.IsNullOrWhiteSpace](http://msdn.microsoft.com/en-us/library/system.string.isnullorwhitespace.aspx)

```
If String.IsNullOrWhiteSpace(theTextBox.Text) Then
    ' process the error.
End If

```

Otherwise [String.IsNullOrEmpty](http://msdn.microsoft.com/en-us/library/system.string.isnullorempty%28v=VS.90%29.aspx)

```
If String.IsNullOrEmpty(theTextBox.Text.Trim()) Then
    ' process the error.
End If

```
Picture the following scenario:

```
var inputString = "      ";      
if (string.IsNullOrWhiteSpace(inputString)
{
}

```

But also note, for future reference (or should your version of the framework not support the above method), that you may have been using `Trim` incorrectly; you can't just call`Trim` to manipulate the string, a new string must be created and therefore you need to assign it, as follows:

```
var trimmedString = inputString.Trim();

```

So, if required, you could do:

```
var inputString = "      ";
if (string.IsNullOrEmpty(inputString.Trim())
{
}

```