Solved

ignoring all spaces with trim function?

Posted on 2003-11-24
3
296 Views
Last Modified: 2010-04-05
Hi

I am trying to write to a text file from the input that the user enters in a maskeditbox, the user enters a numbers but if they leave blank spaces the problem is that the blank spaces also appear in my text file, so when the user enters 555/222/111 its fine but if a user enters
55   / 2  / 1 then the spaces also appear in my text file; i have tried to use trim to solve this problem but it does not work for this situation, my current code is

assignfile(txt, '/home/user/test2.txt');
rewrite(txt);

S:= ' number' + maskedit1.text ;
S:=Trim(s);
WriteLn(txt,s);
closefile(txt);

also is it possible to get rid of the spaces just in the maskedit1? As if i get rid of all the spaces then the number bit will be stuck with the input the user entered such as
number55/2/1  when is i want number 55/2/1  ,

thanks in advance .

0
Comment
Question by:itektas
3 Comments
 
LVL 8

Accepted Solution

by:
gmayo earned 30 total points
ID: 9810548
var s : string; i : integer;

s := '';
for i := 1 to Length(maskedit1.text) do begin
  if maskedit1.text[i] > #32 then s := s + maskedit1.text[i];
end;
maskedit1.text := s;

...now write to file etc...

Geoff M.
0
 

Author Comment

by:itektas
ID: 9810829
thanks! :)
0
 
LVL 19

Expert Comment

by:Limbeck
ID: 9823273
Why not use:

maskedit1.text:=StringReplace(maskedit1.text,' ','',[rfReplaceAll]);

Less code this way ;)

Ed
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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

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

14 Experts available now in Live!

Get 1:1 Help Now