VB Code:
  1. Private Sub txtName_KeyPress(KeyAscii As Integer)
  2. If KeyAscii = 32 Then
  3.    
  4.     If Len(Text1.Text) > 0 Then
  5.        
  6.         If Right$(Text1.Text, 1) = " " Then
  7.             KeyAscii = 0
  8.         End If
  9.    
  10.     End If
  11.  
  12. End If
  13. End Sub