Results 1 to 5 of 5

Thread: delete spaces from string

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Location
    Israel
    Posts
    79

    Question


    how can i delete all spaces from a string ?

    for example: if i have - h e l l o w o r l d
    and i want to make of it: helloworld

    how can i do that ?


  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    spaces

    'replace function in VB6
    'find an instance and replace it with another

    Private Sub Form_Load()

    string1 = "h e l l o w o r l d

    MsgBox string1

    string2 = Replace(string1, " ", "")


    'String1 is now "helloworld"
    MsgBox string2

    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Location
    Israel
    Posts
    79

    Angry

    my mistake, i did not ask the question right.

    i need to delete only spaces befor and after the string.
    the ones in the middle should stay.

    for example:

    [ hello world ]

    will be:

    [hello world]

    how can i do that ?

  4. #4
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Code:
    myStr = " Hello World "
    
    myStr = Trim$(myStr)
    Iain, thats with an i by the way!

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Use the trim function
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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