Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...This forum is the most helpful site I've ever used. I used to use Deja.com; but, this site is better - hands down!..."

Geography

Where in the world do Tek-Tips members come from?

how to now where is the curser location in Tedit

tooraj30 (Programmer)
29 Jul 12 14:39
first i do apologize for my bad english so...
I want my numbers to be three digits separated by three digits in Tedit when user type number in Tedit.
like this :
1234 ---> 1,234
12345 ---> 12,345
1234567890 ---> 1,234,567,890
i use this code and its good but not enough.
in Tedit.onchange :
edit1.text:=seperate(edit1.text);
edit1.selstart:=length(edit1.text);
and seperate function :
function seperate(s:string):string;
var
i:integer;
s1:string;
begin
s1:='';
for i:=1 to length(s) do if copy(s,i,1)<>',' then s1:=s1+copy(s,i,1);
{for delete exist seperator from digit}
if length(s1)<4 then seperate:=s;
if length(s1)=4 then seperate:=copy(s1,1,1)+','+copy(s1,2,3);
if length(s1)=5 then seperate:=copy(s1,1,2)+','+copy(s1,3,3);
if length(s1)=6 then seperate:=copy(s1,1,3)+','+copy(s1,4,3);
if length(s1)=7 then seperate:=copy(s1,1,1)+','+copy(s1,2,3)+copy(s1,5,3);
if length(s1)=8 then seperate:=copy(s1,1,2)+','+copy(s1,3,3)+copy(s1,6,3);
if length(s1)=9 then seperate:=copy(s1,1,3)+','+copy(s1,4,3)+copy(s1,7,3);
...
{etc. on how many digit length that user want it}

end;
now if you write digit simple or delete the last digit by bkspace or delete the code is do right but if you want to delete on of the digit that is in between of digit after the delete curser jump to the end of line becuse of selstart order it means in 123,456,789 if you move the curser behind the 4 and delete it the curser jump to the end but i want to stop the curser in its location down the 5 digit In the above example.
Can someone help?
DjangMan (Programmer)
29 Jul 12 21:22
There are formatting functions that will do this for you. Are you working through this problem to learn something?
tooraj30 (Programmer)
30 Jul 12 2:00
hi
I do not know what you mean is the function
delphi library function? or forigen pakage?
Please specify what exactly function you mean
and last yes i want to control the curser in Tedit for several use
DjangMan (Programmer)
30 Jul 12 8:09
The Format function is built in to Delphi:
http://www.delphibasics.co.uk/RTL.asp?Name=Format
majlumbo (Programmer)
30 Jul 12 11:11
As to your question:

Where is the cursor in a TEdit Component..

Edit1.SelStart;

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close