The topic says it all, does anyone know how I can make it so that I can only make certain text go into an edit box? Say I wanted only wanted integers in one, how can I do this?
- Barrier
The topic says it all, does anyone know how I can make it so that I can only make certain text go into an edit box? Say I wanted only wanted integers in one, how can I do this?
- Barrier
I don't think there's a command to do that in SCAR, but you could do this:
SCAR Code:Edit1.OnChange := @StripLetters;...
procedure StripLetters(Sender: TObject);
var
Numbers: String;
i: integer;
begin
Numbers := '0123456789';
for i := 1 to Length(Edit1.Text) - 1 do
if(Pos(Edit1.Text[i], Numbers) = 0)then
Delete(Edit1.Text, i, 1);
end;
Or something like that....
Interested in C# and Electrical Engineering? This might interest you.
but to be honest , the form will really only return strings
then you just strtoint.
Yes but trying to do that with a value of say 'k' will result in a error meaning that it cant evenn be checked but u could use that as validateion



SCAR Code:program New;
var
frmDesign : TForm;
Label1 : TLabel;
Edit1 : TEdit;
procedure Block2(Sender: TObject; var Key: Char);
var
numbers : string;
begin
numbers := '0123456789' + chr(8);
if pos(key, numbers) = 0 then
begin
Label1.Caption := 'Blocked you from typing ' + key;
Key := Chr(13); //changes key to enter, makes beep plus blocks it. Chr(0) can work too
end;
end;
procedure Init;
begin
frmDesign := CreateForm;
frmDesign.SetBounds(250, 114, 230, 68);
frmDesign.Caption := 'frmDesign';
Label1 := TLabel.Create(frmDesign);
Label1.Parent := frmDesign;
Label1.SetBounds(2, 2, 217, 13);
Edit1 := TEdit.Create(frmDesign);
Edit1.Parent := frmDesign;
Edit1.SetBounds(1, 19, 219, 21);
Edit1.OnKeyPress := @Block2;
frmDesign.ShowModal
end;
procedure Safe;
var
p : TVariantArray;
begin
ThreadSafeCall('Init', p);
end;
begin
Safe;
end.
There are currently 1 users browsing this thread. (0 members and 1 guests)