Solved

ignoring all spaces with trim function?

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi - replicating a form 8 111
How to renew a Delphi rad-studio licence? 5 94
Firemonkey allowing RTL on android 6 77
Using MMsystem To change audio input 1 38
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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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 …

734 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