I have been going throgh the throes of teaching myself Classes only to be beaten at the last hurdle. The class Employee name is a String type, but I wish to place the data in a listbox as an item. I now there is a way make the class a caption, but how?
This is the code:
------------------------------------------
procedure TForm1.AddEmployClick(Sender: TObject);
var emp: Temployee;
var Employnewitem: TListItem;
begin
if financebutton.Checked then
emp := FinEmployee.create(EmployName.Text, strtoint(employsal.Text));
Employnewitem:= EmployView.Items.Add;
Employnewitem.Caption := (emp.name)
//Employnewitem.ImageIndex := 0
else
emp := salesEmployee.create(EmployName.Text, strtoint(employsal.Text), 10);
Employnewitem:= EmployView.Items.Add;
Employnewitem.Caption := (emp.name);
//Employnewitem.ImageIndex := 1;
end;
-----------------------------------------------
Here is the error:
----------------------------------------------
[Warning] Unit1.pas(50): Variable 'emp' might not have been initialized
[Error] Unit1.pas(53): 'END' expected but 'ELSE' found
[Fatal Error] Project1.dpr(8): Could not compile used unit 'Unit1.pas'
--------------------------------------------------
This is the code:
------------------------------------------
procedure TForm1.AddEmployClick(Sender: TObject);
var emp: Temployee;
var Employnewitem: TListItem;
begin
if financebutton.Checked then
emp := FinEmployee.create(EmployName.Text, strtoint(employsal.Text));
Employnewitem:= EmployView.Items.Add;
Employnewitem.Caption := (emp.name)
//Employnewitem.ImageIndex := 0
else
emp := salesEmployee.create(EmployName.Text, strtoint(employsal.Text), 10);
Employnewitem:= EmployView.Items.Add;
Employnewitem.Caption := (emp.name);
//Employnewitem.ImageIndex := 1;
end;
-----------------------------------------------
Here is the error:
----------------------------------------------
[Warning] Unit1.pas(50): Variable 'emp' might not have been initialized
[Error] Unit1.pas(53): 'END' expected but 'ELSE' found
[Fatal Error] Project1.dpr(8): Could not compile used unit 'Unit1.pas'
--------------------------------------------------