Remove the ' ' (blanks spaces) from combobox1 item ?

Posted on 2003-02-25
Medium Priority
Last Modified: 2010-04-04
Hi team
This is a simple one but I can't get it right Grrrr.  
I need to copy only the bytes or text with values from combobox1.itemindex.

The item has 20 bytes in it.  The first so many contain a name and the rest is blank up to 20.  If I use the whole line for a label name, and set autosize to true, the label width obviously sizes itself to fit 20 characters.

What is the code to only copy until that line shows a blank ' '  ????

Thanks in advance


p.s.  The blank spaces need to be in the combobox for a reason.
Question by:Mark Brady
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
LVL 27

Accepted Solution

kretzschmar earned 200 total points
ID: 8018809
what about the trim function

you can use it by adding like

combobox1.items.add(trim('SomeValue         '));

or when you retrieve

somevar := trim(combobox1.items[combobox1.itemindex]);
somevar := trim(combobox1.text);

see also trimleft or trimright

meikl ;-)

Expert Comment

ID: 8019651
function GetOnlyTextWithoutBlanks(Str: String): String;
  Str := StringReplace(Str, ' ', EmptyStr, [rfReplaceAll]);
  Result := Str;

That will get any spaces before or after the text, and return only the text.

LVL 20

Author Comment

by:Mark Brady
ID: 8023004
Excellent !!!  So simple and yet so far from my reach lol.  That is a great little function that I have never heard of.  Thank you so much.


Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

762 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