Click here to Skip to main content
15,877,915 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am attempting to write a program where when a user enters a word in a text box the program will display the word entered, the number of characters the word is, and what the first and last letters are of the word. The problem I'm having is when someone enters two words, the program is supposed to display an error telling them to enter one word only. What my program does though is it still acts as if it is one word. For example, if some one enters, Hell o, it still says the word is Hello with 6 characters, 1st letter H, last letter O.

What I have tried:

I have tried to have the program search for a space using the ascii character code 32, but it seems to just ignore if there is a space or not.
Posted
Updated 8-Mar-16 23:34pm

1 solution

Try:
VB
If myTextBox.Text.Contains(" ") Then
	MessageBox.Show("One word only, please!")
	Return
End If
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900