title: Delphi: getting access violation error at run-time
body: <p>I'm pretty new to Delphi and am attempting to use different units to store TLists and TObjects, as well as generate other combobox options based on previous combobox selections. I am receiving the following error messages immediately after running:</p>
  <blockquote>
  <p>Project Project1.exe raised exception class $C0000005 with message
  'access violation at  0x004087d7: read of address 0x00000000</p>
  <p>Access violation at address 00408813 in module 'Project1.exe'. Read of
  address 00000000.</p>
  </blockquote>
  <p>I've traced through the steps in the debugging tool but I can't see why it won't work. I have googled the issue and have found a few solutions but nothing that seems like it applies to my current problem.</p>
  <pre><code>unit MainForm;
  
  interface
  
  uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
  
  type
    TfMain = class(TForm)
      lCPU: TLabel;
      cbCPU: TComboBox;
      lGPU: TLabel;
      cbGPU: TComboBox;
      lMotherboard: TLabel;
      cbMotherboard: TComboBox;
      lRAM: TLabel;
      cbRAM: TComboBox;
      eCompatible: TEdit;
      lCompatible: TLabel;
      eCost: TEdit;
      lCost: TLabel;
      Label11: TLabel;
      lbCPU: TListBox;
      lbMotherboard: TListBox;
      lbGPU: TListBox;
      lbRAM: TListBox;
      procedure FormShow(Sender: TObject);
      procedure cbCPUChange(Sender: TObject);
    private
      { Private declarations }
    public
  //    procedure cbCPUpopulate();
    end;
  
    type TGPU = class(TObject)
      public
        name : string;
        vram : integer;
        clock : integer;
        price : string;
    end;
  
    type TCPU = class(TObject)
      public
        name : string;
        cores : integer;
        clock : real;
        intel : boolean;
        amd : boolean;
        price : string;
    end;
  
    type TMobo = class(TObject)
      public
        name : string;
        intel : boolean;
        amd : boolean;
        price : string;
    end;
  
    type TRAM = class(TObject)
      public
        name : string;
        memory : integer;
        clock : integer;
        price : string;
    end;
  
  var
    fMain: TfMain;
  
  implementation
  
  {$R *.dfm}
  
  uses CPUs, GPUs, Motherboards;
  
  procedure TfMain.cbCPUChange(Sender: TObject);
  var
  i : integer;
  mobo : TMobo;
  begin
    if TCPU(fMain.cbCPU.ItemIndex).intel = true then begin
      for i := 0 to Motherboards.MoboPartsList.Count-1 do begin
        mobo := TMobo(Motherboards.MoboPartsList.Items[i]);
        if mobo.intel = true then begin
          fMain.cbMotherboard.Items.AddObject(mobo.name, mobo);
        end;
      end;
    end;
  end;
  
  procedure cbCPUpopulate();
  var
  i : integer;
  CPU : TCPU;
  begin
    for i := 0 to CPUs.CPUPartsList.Count-1 do begin
      CPU := TCPU(CPUs.CPUPartsList.Items[i]);
      fMain.cbCPU.Items.AddObject(CPU.name, CPU);
    end;
  end;
  
  procedure TfMain.FormShow(Sender: TObject);
  begin
    Motherboards.MakeMoboList;
    CPUs.MakeCPUList();
    GPUs.popgpulist();
    cbCPUpopulate;
  end;
  
  end.
  </code></pre>