Solved

New to delphi

Posted on 2002-05-29
5
140 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now