I need no space at end of my string

I Need to read from a file and
I don’t now the length of  "Ch6"
It can be 18 character long
I put it in a form.edit.text
and I need not the space from right.

I try the TrimRight but it take the space to

ex1…
Edit3.Text:=TrimRight(copy(Ch6,20,18));

ex2..        
Edit3.Text:=copy(Ch6,20,18);
Edit3.Text:=TrimRight(Edit3.Text)

……………………………..

I test the length on Edit3 and it still is 18

    Edit7.Text:=IntToStr(Length(Edit3.Text));

Are I stupid or is it wrong to do like this..

Help/janne  
LVL 6
Dark_KingAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
PeterLarsenConnect With a Mentor Commented:
I tried this and found no problems !!??!!

procedure TForm1.Button14Click(Sender: TObject);
var
d : string;
begin
d:='002af608a7e8      RUM322             Rum322-01';
edit1.text:=trim(copy(d,19,18));
edit2.text:=inttostr(length(edit1.text));
end;

Regards
Peter
0
 
PeterLarsenCommented:
I you sure that the last character is a chr(32) and not a different one ?? And have you tried to use TRIM ??
0
 
Dark_KingAuthor Commented:
I read from a text file and it is space after a word
Ex
002af608a7e8      RUM322             Rum322-01

Example if I need the RUM322 I copy start to length (Fixed length) 18 characters ..
In this case copy(Ch6,19,18);

then I reg. it to windows register
It while be wrong if I not can use TRIM
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Dark_KingAuthor Commented:
I read file like this

if  FileExists(mac1) Then
    begin
    AssignFile(F1,  mac1) ;

    Reset(F1);
     while not Eof(F1) do
      begin
        Readln(F1, Ch6);
0
 
Dark_KingAuthor Commented:
Is edit2.text = 6 or 18
I wont it to be 6
0
 
PeterLarsenCommented:
In my sample it have a length of 6.
0
 
Dark_KingAuthor Commented:
I stupide I look at frong text
Sorry
you still Earn the 10 points

Thanks
0
 
PeterLarsenCommented:
:-)
0
All Courses

From novice to tech pro — start learning today.