Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

New to delphi

Posted on 2002-05-29
5
Medium Priority
?
147 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 200 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

705 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