Closed Thread
Results 1 to 6 of 6

Thread: Is there a function to do this?

  1. #1
    2710 is offline Programmer
    Join Date
    Sep 2008
    Posts
    108
    Rep Power
    0

    Is there a function to do this?

    Hi,

    Take this sentence for example. Would it be possible to have a function so that it extracts all the spaces leaving this: 'Takethissentenceforexample' ?

    Thanks.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    2710 is offline Programmer
    Join Date
    Sep 2008
    Posts
    108
    Rep Power
    0

    Re: Is there a function to do this?

    Also one more question

    I have a listbox with some products. I have programmed the program to add 'clicked' item from listbox1, to listbox2 when the button 'Add' is clicked, kinda like a shopping basket. Ie. highlighted item is added to listbox2 when 'Add' is clicked.

    Now, the thing is, what happens when I dont highlight an Item and just click Add? Well I tried it, and it added 'h9E' to listbox2. Have no idea what this means. Anyway to fix this bug?

    Thanks

  4. #3
    Join Date
    Apr 2009
    Location
    Trapped in my own little world.
    Posts
    2,487
    Rep Power
    33

    Re: Is there a function to do this?

    Yes, if I were you, I would start and learn some regular expressions, you have no idea how useful these can be later in your programming life.

    RegEx in Delphi - Regular Expression Libraries for Delphi

  5. #4
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: Is there a function to do this?

    To eliminate spaces, just use stringreplace(string,' ','', [rfReplaceAll]).
    String handling routines - Delphi Programming
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  6. #5
    2710 is offline Programmer
    Join Date
    Sep 2008
    Posts
    108
    Rep Power
    0

    Re: Is there a function to do this?

    Thanks to both of you.

    Thanks BlaineSch, but Im still a noob. Apparently that regex thing is pretty complex? But some people say its really useful, so Ill read up on it. Is this regex thing kinda like only letting the person enter a Letter for the first character for the postcode field? and a number for the 3rd etc? Thanks

    And thanks WingPanther

  7. #6
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: Is there a function to do this?

    RegEx allows you to do a wide variety of string validation and substitutions. It is very powerful, and not that hard to learn. Depending on the version of Delphi you have, you may or may not have access to it without downloading and installing a component, however.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. function and function calls
    By jackson6612 in forum C and C++
    Replies: 10
    Last Post: 05-05-2011, 11:37 AM
  2. Replies: 1
    Last Post: 03-20-2011, 06:16 AM
  3. Replies: 3
    Last Post: 11-12-2010, 05:47 PM
  4. How do I use a variable in a function from a previous function?
    By system32 in forum JavaScript and CSS
    Replies: 2
    Last Post: 02-09-2010, 09:57 AM
  5. Looking for a function
    By Kylo in forum Visual Basic Programming
    Replies: 7
    Last Post: 04-25-2008, 04:52 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts