Solved

New to delphi

Posted on 2002-05-29
5
145 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
[X]
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
  • 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

739 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