Solved

New to delphi

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
oracle global variables 4 63
LAN or WAN ? 11 81
Delphi and Access based Enumeration 9 44
I want to use librsync in my Delphi backup application. 3 25
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…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

932 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

9 Experts available now in Live!

Get 1:1 Help Now