Hi All,

I am very new to DELPHI PASCAL Programming.
I have imported the TLB file using Component->Import Component. I would like to use the class of the component and call its method.

for that i have declared class object like
TSam1 = class(SampleClass)

and called the method of it as


I am getting "E2076 This form of method call only allowed for class methods." Can anyone please guide me, where i am going wrong.


Recommended Answers

All 2 Replies

i'm not sure what TLB is..can you give more details about this?

The problem is that you are referring to the TYPE TSam1 when you call your method. That is only possible if the method is a class method (and if you're a new student, you won't have heard about class methods yet). What you need to do is declare a variable of the type TSam1, create an instance of that type and assign it to the variable and then use the variable to call your method:

mySam :TSam1
mySam := TSam1.Create;

PS- why are you declaring TSam1 at all? The way your code reads, it is exactly the same as SampleClass and is unnecessary. Maybe you were attempting to create an instance of SampleClass named TSam1, in which case your syntax was incorrect.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.