We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,485 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Validation to ensure something is an integer

This procedure is called just before the answer is written to a binary file to ensure it is in the correct format. It works but I need it to repeat until it is an integer. I was trying to use a 'repeat','until' but wasnt sure what the 'until' condition woudld be. At the moment it displays the message and then carries on regardless.

Procedure ValidateAnswer;
begin
 try
  ValidatedAnswer:=StrToInt(QuestionnaireForm.Answer.Text);
 except
 ShowMessage('Answer must be an integer');
 end;
end;

Thanks!

2
Contributors
3
Replies
17 Hours
Discussion Span
3 Months Ago
Last Updated
7
Views
Blousey17
Newbie Poster
4 posts since Nov 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

I don't think it can be done in it's current form. The input text will never change inside any loop, so it will be endless. Please explain what you are trying to achieve. (or perhaps some more code)

pritaeas
Posting Prodigy
Moderator
9,316 posts since Jul 2006
Reputation Points: 1,178
Solved Threads: 1,467
Skill Endorsements: 86

I am writing answers to a binary file. The answer to one of the questions needs to be an integer. So that the program doesn't crash I need to make sure it is an integer before assigning it into the binary file.

I ideally want it to display the message and then go back to the form allowing someone to correct their answer. At the moment It just displays the message and then carries on regardless.

I suppose I don't want a 'repeat' but I don't want it to do anything else such as writing to the file until this answer has been changed.

Hope that makes sense!

Blousey17
Newbie Poster
4 posts since Nov 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Yes it does, but without seeing the flow of your code, suggesting a solution is very hard.

pritaeas
Posting Prodigy
Moderator
9,316 posts since Jul 2006
Reputation Points: 1,178
Solved Threads: 1,467
Skill Endorsements: 86

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0717 seconds using 2.65MB