procedure TForm1.Button2Click(Sender: TObject);var aux:integer;begin Try aux:=StrToInt(edit1.Text); scrollbar1.Position:=aux; except On Exception do scrollbar1.Position:=0; end;end;
if edit1.text <> '' thenbegin [...]end
uses ... , SysUtils, ...;
StrToIntDef(Edit1.Text, 0);
var aux :integer;begin aux := StrToIntdef(Edit1.Text, 0); if aux = 0 then ShowMessage('Invalid integer value'); scrollbar1.Position := aux;end;
Very cool! it worked out!But could you explain to me a little bit how this function works?
aux:=StrToIntDef(edit1.text, -1);if aux=-1 then ShowMessage('!!!')else scrollbar.position:=aux;