Solved

ignoring all spaces with trim function?

Posted on 2003-11-24
3
300 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
[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
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

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