What's wrong with this code?

try
test := strtoint(edit1.Text);
except
on EConvertError do ShowMessage('Convertion error') ;
end;

I want to check whether edit1.text contains a non-number character or not. Any idea?

thanks in advance

Comments

  • : try
    : test := strtoint(edit1.Text);
    : except
    : on EConvertError do ShowMessage('Convertion error') ;
    : end;
    :
    : I want to check whether edit1.text contains a non-number character or not. Any idea?
    :
    : thanks in advance
    :
    The code looks fine to me, as long as test is an integer variable. If you could tell us the error you're getting, perhaps we can give you more advice.
  • When you run the program directly from Delphi, you will get an exception, even you have made this TRY and EXCEPT programming.
    If you try to run the .exe file after you have compiled your project, then the program will work, and you will not get the error (exception). If you do want to run the program from Delphi without getting this (unnecessarily) exception, you can turn this function off:
    Tools | Debugger Options... | Language Exceptions | Stop on Delphi Exceptions.

    Regards
    CLCase

  • : When you run the program directly from Delphi, you will get an exception, even you have made this TRY and EXCEPT programming.
    : If you try to run the .exe file after you have compiled your project, then the program will work, and you will not get the error (exception). If you do want to run the program from Delphi without getting this (unnecessarily) exception, you can turn this function off:
    : Tools | Debugger Options... | Language Exceptions | Stop on Delphi Exceptions.
    :
    : Regards
    : CLCase
    :
    :

    Yuhuu, I Got IT! thank you very much... =)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories