Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

New to delphi

Posted on 2002-05-29
5
143 Views
Last Modified: 2010-04-04
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

0
Comment
Question by:kiddiec
  • 2
  • 2
5 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7043137
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 ;-)
0
 
LVL 9

Accepted Solution

by:
ginsonic earned 50 total points
ID: 7043678
You have two questions ? Not sure but ...

For first part (how do I centre text in a textedit box?)read next tip:
http://www.swissdelphicenter.ch/torry/showcode.php?id=714

For second part if use in an application use :

procedure TForm1.FormCreate(Sender: TObject);
begin
 code1 := 'PASSWORD';
 code2 := 'USERNAME';
end;

if use these into a component :

constructor TYourComponent.Create(AOwner: TComponent);
begin
 inherited Create(AOwner);
 code1 := 'PASSWORD';
 code2 := 'USERNAME';
end;
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 7043681
For the first question can read next tip , too .

http://www.lmc-mediaagentur.de/dpool/tips11/1096.htm
0
 
LVL 2

Author Comment

by:kiddiec
ID: 7043779
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
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7043851
hmmm...
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question