Results 1 to 13 of 13

Thread: add two strings without space

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Location
    greece athens
    Posts
    115

    add two strings without space

    anybody can tell me how to add two strings without space between them
    for example string1= string2 & string3

  2. #2
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: add two strings without space

    well what you have posted works just the way you want it
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Location
    greece athens
    Posts
    115

    Re: add two strings without space

    yes but in string1 it is a space between two strings(string1 and string2)
    but i want it without space

  4. #4
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: add two strings without space

    That means there is a space at the start or end of one of your strings. Try:

    VB Code:
    1. string1= RTrim$(string2) & LTrim$(string3)

  5. #5
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: add two strings without space

    what do you mean? do you mean that there is a space in string 1

    if you want no spaces then you can use
    VB Code:
    1. replace(string1," ", "")
    2. replace(string2," ", "")
    then do your code
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Location
    greece athens
    Posts
    115

    Re: add two strings without space

    many thanks you saved me!!!!!!!!

  7. #7
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: add two strings without space



    Don't forget to mark this thread resolved

  8. #8
    Frenzied Member wiz126's Avatar
    Join Date
    Jul 2005
    Location
    Mars,Milky Way... Chit Chat Posts: 5,733
    Posts
    1,080

    Re: add two strings without space

    Quote Originally Posted by d3gerald
    what do you mean? do you mean that there is a space in string 1

    if you want no spaces then you can use
    VB Code:
    1. replace(string1," ", "")
    2. replace(string2," ", "")
    then do your code
    Just to add, you didn't have to do it twice if all you want is string1 without space:
    VB Code:
    1. string1 = Replace((string2 + string3), " ", "")

    Also if this thread have been resovled place click on Thread Tools -> Mark Thread Resolved
    1) If your post has been adequately answered please click in your post on "Mark Thread Resolved".
    2) If someone has been useful to you please show your respect by rating their posts.
    3) Please use [highlight="VB"] 'your code goes in here [/highlight] tags when posting code.
    4) Before posting your question, make sure you checked this links:
    MICROSOFT MSDN -- VB FORUMS SEARCH

    5)Support Classic VB - A PETITION TO MICROSOFT

    ___________________________________________________________________________________
    THINGS TO KNOW ABOUT VB: || VB Examples/Demos
    What are Classes?
    || -
    Where to place a sub/function?(global) || Webbrowser control

  9. #9
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: add two strings without space

    wiz126 : nice, but instead of using + use & because if the variables are just numbers it will add those
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  10. #10
    Hyperactive Member vbcode1980's Avatar
    Join Date
    Nov 2005
    Location
    Anywhere the wind blows
    Posts
    365

    Re: add two strings without space

    Not to critisize, but removing all spaces from a string might not be wise.
    The spaces inside the string might be part of it (a sentence or something).
    Best is to trim the spaces of the ends.
    I code C#....

  11. #11
    Frenzied Member litlewiki's Avatar
    Join Date
    Dec 2005
    Location
    Zeta Reticuli Distro:Ubuntu Fiesty
    Posts
    1,162

    Lightbulb Re: add two strings without space

    Quote Originally Posted by ganeshmoorthy
    wiz126 : nice, but instead of using + use & because if the variables are just numbers it will add those
    point to be noted...
    __________________
    ________________0îîî___
    ___îîî0________(___)____
    __(___)_________) _/_____
    ___\_ (_________(_/______
    ____\_)_________________

  12. #12
    Hyperactive Member Datacide's Avatar
    Join Date
    Jun 2005
    Posts
    309

    Re: add two strings without space

    VB Code:
    1. string1 = Trim(string2) & Trim(string3)
    PHP in your FACE!

  13. #13
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: add two strings without space

    Quote Originally Posted by Datacide
    VB Code:
    1. string1 = Trim(string2) & Trim(string3)
    He may not want to remove the leading spaces of string2 or the trailing spaces of string3.

Posting Permissions

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



Click Here to Expand Forum to Full Width