title: Use object with variable name in Delphi
body: <p>I'm new in delphi and i thought it might be safer to swap object names in loop instead of copying whole block for each object. So I need to use variable name as some objects name.
  Here is an example of what i tried and what i am trying to do.</p>
  
  <pre><code>  Var
      YazGrid: TStringGrid;
  </code></pre>
  
  <p>I defined a variable for grid name as above and i am trying to use like this:</p>
  
  <pre><code>  Some Loop
      begin
        if a_variable&gt;=10 then
          YazGrid:=form1.StringGrid1
        else
          YazGrid:=form1.StringGrid2;
  
        YazGrid.Cells[1,i] := 'SomeText';
      End;
  </code></pre>
  
  <p>As the result- it comes out with the "Access Violation" error. How should i do this?</p>
  
  <p>Thanks in advance.</p>