![]() |
problem with accessing value
Dear All,
I have two units, Unit1 and Unit2 , i would like to access a boolean from Unit1 to Unit2 , i have tried it in the following way, but i have got the error "Zugriffsverletzung bei Adresse 023C4B58 in Modul 'Test.exe'. Lesen von Adresse 0000"
Code:
could you please tell me ,how can i make it works?
//Unit1
Unit Unit1 type TCalculation = class(TForm) private protected FNewvalue: Boolean; public property Newvalue: Boolean read FNewvalue; end; //Unit2 Unit Unit2 type Taccounts = class(TForm) interface uses Unit1 private protected public procedure Checkvalue(Sender: TObject); end; implementation procedure Taccounts .Checkvalue(Sender: TObject); var f : TCalculation ; // i have created an instance of TCalculation begin if f.Newvalue = True then // i have called the boolean //check the condition End; |
AW: problem with accessing value
Zitat:
Where is your created instance of 'TCalculation'? |
AW: problem with accessing value
Could you please tell me ,how can i create the instance of 'TCalculation'? i am reading some tutorial,but i am not so clear, could you please give me an example ?
|
AW: problem with accessing value
Zitat:
Delphi-Quellcode:
var
f: TCalculation; // declaration begin f := TCalculation.Create; // create instance ... |
AW: problem with accessing value
Hi , i got the error " Nicht genünged wirklich parameter"
Code:
var
f: TCalculation; begin f := TCalculation.Create; // Here pointing the error("Nicht genünged wirklich parameter") ... |
AW: problem with accessing value
TCalculation is of kind TForm, whose constructor expects an Owner-parameter. If you don' t want to set an owner, simply pass nil.
Delphi-Quellcode:
I think you should read some basics-tutorial, e.g.
f := TCalculation.Create(nil);
![]() |
AW: problem with accessing value
Thanks for the link, i am following this tutorial,but i have another question, i have done the progem, now there is no error,but i am not getting the expected value of Modified(its a Boolean var)
Code:
var
f: TCalculation; begin f := TCalculation.Create(nil); if f.FNewvalue = True then // the FNewvalue is always zero, which is unexpected //this will hapen else //this end; |
AW: problem with accessing value
This is not unexpected, you create a new instance, therefore its properties are set to default unless something happens which changes them.
[edit] BTW: You should never compare to true or false, this can lead to unexpected results.
Delphi-Quellcode:
-->
if var = true then
Delphi-Quellcode:
[/edit]
if var then
|
AW: problem with accessing value
Is it also possible to create a class exactly as it is(not as a new instance), i mean i want to create a class of TCalculation so that i can access any of its variable with the exact value from class of TAccounts
i even dont know whether its possible or not, i was looking in tutorial but dont get any idea yet, can you please help me ? |
AW: problem with accessing value
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:31 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