AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

access value by Property

Ein Thema von question · begonnen am 22. Aug 2013 · letzter Beitrag vom 23. Aug 2013
Antwort Antwort
question

Registriert seit: 17. Apr 2013
97 Beiträge
 
#1

AW: access value by Property

  Alt 22. Aug 2013, 17:19
Here is the sample code please

Code:
unit Unit1;
{

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
  TForm1 = class(TForm)
   
  private
    FNewID : Integer;  
  public
    property NewID : Integer read FNewID;
    Person (ID : Integer);
  end;

var
  Form1: TForm1;
 
implementation


{$R *.DFM}
{$R common.res}

procedure TForm1.Person (ID : Integer);
begin
//here i get the value of ID after query from Database
//for example I have got ID=20;
end;

procedure TForm1.btnOkClick(Sender: TObject);
begin
if True then //after check the condition, i wanna call
Form1.Person (ID); // here how can i initialize ID so that i get the value 20
end;

end.

Geändert von question (22. Aug 2013 um 17:21 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von DeddyH
DeddyH

Registriert seit: 17. Sep 2006
Ort: Barchfeld
27.662 Beiträge
 
Delphi 12 Athens
 
#2

AW: access value by Property

  Alt 22. Aug 2013, 17:25
You can use a function instead of a procedure, or you can pass the parameter by reference.
Delphi-Quellcode:
function TForm1.Person: integer;
begin
  Result := <ID retrieved by query>;
end;

procedure TForm1.Person(out ID: integer);
begin
  ID := <ID retrieved by query>;
end;
If you want to access the parameter inside the procedure, use "var" instead of "out".
Detlef
"Ich habe Angst vor dem Tag, an dem die Technologie unsere menschlichen Interaktionen übertrumpft. Die Welt wird eine Generation von Idioten bekommen." (Albert Einstein)
Dieser Tag ist längst gekommen
  Mit Zitat antworten Zitat
question

Registriert seit: 17. Apr 2013
97 Beiträge
 
#3

AW: access value by Property

  Alt 22. Aug 2013, 18:54
Thanks for suggestion

but how can i initialize the ID:Integer in event handler, becasue in event handler i cannot add any parameter, for example

Code:
procedure TForm1.Button1click(Sender: Tobject);// i cannot set anyother parameter,then delphi compiler automatic delete the adding parameter
begin
 //here i need the value of ID,which is for example 20, if i declare var ID: Integer here then it give me the value 0
end;
end.
  Mit Zitat antworten Zitat
Benutzerbild von DeddyH
DeddyH

Registriert seit: 17. Sep 2006
Ort: Barchfeld
27.662 Beiträge
 
Delphi 12 Athens
 
#4

AW: access value by Property

  Alt 22. Aug 2013, 19:03
Delphi-Quellcode:
procedure TForm1.Button1click(Sender: Tobject);
var
  ID: integer;
begin
  Person(ID); //Now ID should have the value which is retrieved by your query
end;
Detlef
"Ich habe Angst vor dem Tag, an dem die Technologie unsere menschlichen Interaktionen übertrumpft. Die Welt wird eine Generation von Idioten bekommen." (Albert Einstein)
Dieser Tag ist längst gekommen
  Mit Zitat antworten Zitat
question

Registriert seit: 17. Apr 2013
97 Beiträge
 
#5

AW: access value by Property

  Alt 22. Aug 2013, 19:41
I have tried it but then i found the value of id

Code:
Procedure TForm1.Person(ID : Integer);
begin
//here the query excuted with a value of ID which comes from another procedure
//therefore to use the function its a lot more change in whole code
// i think in my situation pass parameter by reference will be best way
end;

it would be kind of you, if you give me a small example concerning my situation in order to pass the parameter by refrence from Procedure TForm1.Person(ID : Integer); to Procedure TForm1.Button1Click(Sender: TObject);
  Mit Zitat antworten Zitat
Benutzerbild von DeddyH
DeddyH

Registriert seit: 17. Sep 2006
Ort: Barchfeld
27.662 Beiträge
 
Delphi 12 Athens
 
#6

AW: access value by Property

  Alt 23. Aug 2013, 07:16
The OnClick-Event is a TNotifyEvent, you cannot change this. I still don' t know what you want to do exactly, maybe a little explanation could be helpful.
Detlef
"Ich habe Angst vor dem Tag, an dem die Technologie unsere menschlichen Interaktionen übertrumpft. Die Welt wird eine Generation von Idioten bekommen." (Albert Einstein)
Dieser Tag ist längst gekommen
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:33 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz