-2

Here is the code now:

procedure TForm1.Button1Click(Sender: TObject);
var j,r:integer; k:string;
begin
  k := Edit1.Text;

  if StrToInt(k) > 0 then 
    if StrToInt(k)<10 then
      r := StrToInt(k);
  if StrToInt(k) = 10 then
    r := 1;
  if StrToInt(k) > 10 then 
    if StrToInt(k) < 190 then
      j:=StrToInt(k) mod 10;
  r := j-1;

  ShowMessage('Na toj poziciji se nalazi: '+ IntToStr(r));
end;

When I write k:=Edit1.Text option is not even suggested to use. Anybody got a solution?

6
  • Welcome to SO! To assign text from TEdit instance to your Integer variable, you can use StrToInt function and specify Edit.Text` as its argument. Commented Oct 18, 2018 at 12:55
  • @Edin You edit has been reverted because you cannot ask new questions by editing existing questions. If you have a new question, please ask a new question. However, please don't view this site as a means to get others to do your work for you. If you are stuck on beginner mistakes, spend at least some time researching how to fix them. At the very least read the error messages and warnings and try to think what they mean. Commented Oct 18, 2018 at 14:38
  • it was disuscussion about the same program lol Commented Oct 18, 2018 at 15:07
  • Yes I know. But here on SO we ask one question at a time. Once you have an answer, the question is over. It's fine to edit the question to improve or clarify the original question, but not to ask new questions. I believe this is covered by the topics at the help center. Commented Oct 18, 2018 at 15:09
  • FWIW, calling StrToInt(k) everywhere is not really a good idea. The conversion from string to integer takes time and doing it again and again will slow down your program (ok, not this trivial code, but it could become important in a larger project). Rather do myInt := StrToInt(k); once and then use that integer instead. Commented Oct 18, 2018 at 21:09

1 Answer 1

0

you are trying to set 'k', which is declared an integer, to a string from Edit1.Text

Convert Edit1.Text to an integer using StrToInt and try it again. BTW the message: "Incompatabile types: 'Integer' and 'TCaption'" means exactly that. It's incompatible.

Sign up to request clarification or add additional context in comments.

3 Comments

I apologize I'm new at the forum/site, but I'm having problems with sendning comments. Is there any way where I can do everything same as making a post?
@EdinHajdarevic, if you want add something important, you can edit your own question. Just click edit button below your question and add information.
checkout the post now

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.