Link to home
Start Free TrialLog in
Avatar of kiddiec
kiddiec

asked on

New to delphi

how do I centre text in a textedit box?

I have declared two variables in the private declaration section  as follows

Private
code1:string;
code2:string

When I try to declare and set them at the same time

code1:string :='PASSWORD';
code2: string :='USERNAME'
I get an error

and when I try to use the variables elsewhere I also get errors.  I have tried the help files bat cannot find anywhere that describes how and where to set the variables

Avatar of kretzschmar
kretzschmar
Flag of Germany image

hi,

as far as i know,
is this
>code1:string :='PASSWORD';
only allowed for global vars

initialize youe private members in your create-constructor of your object like

constructor TYourObjectName.Create(MaybeParameters);
begin
  inherited create(MaybeParameters);
  code1 := 'PASSWORD';
  code2 := 'USERNAME';
end;

or if it a form-object,
then use the oncreate-event for this
(no inherited is needed there)

hope this helps

meikl ;-)
ASKER CERTIFIED SOLUTION
Avatar of ginsonic
ginsonic
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
For the first question can read next tip , too .

http://www.lmc-mediaagentur.de/dpool/tips11/1096.htm
Avatar of kiddiec
kiddiec

ASKER

Thank you, most helpful.

I have come from a vb background and am impressed with Delphi so far, although the help files seem a bit unhelpful
hmmm...