Validating String Characters as Numeric w/ Pascal (FastReport 4)
- by user2525015
I'm new to Pascal and FastReport. This question can probably be answered without knowledge of FastReport. Pascal is Delphi. FastReport4.
I have a text box accepting an 8 character string as input. Each character should be numeric. I'm attempting to validate each character as numeric. I've tried using the val function...
Procedure Val(S : String; var R: Real; Code : Integer);
begin
end;
procedure thisinputOnChange(Sender: TfrxComponent);
var
S : String;
error : Integer;
R : Real;
begin
S := thisinput.lines.text;
Val (S, R, error);
If error > 0 then
Button2.enabled := False;
end;
I got this code online. The explanation says that the function will return an error with a code greater than zero if the character cannot be converted to an integer. Is that explanation correct? Am I misinterpreting?
Right now I am trying to set a button's enabled property to false if the validation fails. I might change that to a message. For now, I would like to get it to work by setting the button property.
I'm not sure if I should be using the onChange event or another event. I'm also not sure if I need to send the input to the val function in a loop. Like I said, I'm just learning how to use this function.
I am able to validate the length. This code works...
procedure thisinputOnChange(Sender: TfrxComponent);
begin
if length(thisinput.lines.text) = 8 then
Button2.enabled := True;
end;
Any suggestions? Should I use the val function or something else? Let me know if I need to provide more info. I might not be able to check back until later, though.
Thanks for any help.