Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 131,577 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,963 people online right now. Registration is fast and FREE... Join Now!




Message Box and if statements in Borland C++

 
Reply to this topicStart new topic

Message Box and if statements in Borland C++, Bit of help??

oggy36
post 25 Nov, 2005 - 04:54 AM
Post #1


New D.I.C Head

*
Joined: 25 Nov, 2005
Posts: 2


My Contributions


Can anyone tell me how to prompt a message box when character is entered into a text box, when only integers are required much appriciated!
User is offlineProfile CardPM

Go to the top of the page


oggy36
post 25 Nov, 2005 - 05:04 AM
Post #2


New D.I.C Head

*
Joined: 25 Nov, 2005
Posts: 2


My Contributions


QUOTE(oggy36 @ 25 Nov, 2005 - 06:51 AM)
Can anyone tell me how to prompt a message box when character is entered into a text box, when only integers are required much appriciated!

if (txtEdit1-> Text== ?????)

It aint char... any suggestions??

if (txtEdit1-> Text== ?????)

It aint char... any suggestions??
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 25 Nov, 2005 - 06:51 AM
Post #3


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,158



Thanked 32 times

Dream Kudos: 25
My Contributions


If it is only one character that you are checking, then simply use the isdigit() function
CODE

if (isdigit(txtEdit1-> Text)==0)
  ShowMessage("Integers only, please.");

If it is a string of characters, then set a boolean flag to true...traverse the string in a for loop testing each character with isdigit..if it returns false anywhere, set the flag to false, break the loop, test the flag condition, and print the message.
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/20/08 03:23AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month