i can trap Number only but i cant trap letter inputs. how to do that? please?

example.

Enter a letter: 5

"INVALID INPUT! PLEASE ENTER A NUMBER!"

please guys?!

Recommended Answers

All 2 Replies

The Character class has methods for testing isLetter etc. You'll find the doc in the usual place.

i can trap Number only but i cant trap letter inputs. how to do that? please?

example.

Enter a letter: 5

"INVALID INPUT! PLEASE ENTER A NUMBER!"

please guys?!

if you want us to see where you're going wrong in your code, you'll have to show us your code, not what you get on your DOS prompt.

for instance, if you've coded it to generate an error message as soon as you enter '5', then your code is working perfectly fine, but impossible for us to know.
Since we also can't see what you're using to read the char, are you sure he's not taking the blank space that stands before the 5?

depending on your code, that might give a problem as well.

but most important is: what exactly do you need? do you need to read characters, or will you, on some point, have to read input that contains more than one char?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.