Use The Following Code :
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Select Case Asc(e.KeyChar)
Case 32
e.Handled = True
MessageBox.Show("You Can Not Enter Space Here!")
Case Else
End Select
End Sub
Or Else If you Just don't want to allow to enter Single Space in TextBox Use this one :
IF Trim(TextBox1.Text)="" Then
MessageBox.Show("Please Enter Data Here!")
Else
End If
I Hope It Will Help You!:)