Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Park City, Utah
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Deletes Space in Variable (Word VBA)

    What code wold I use to check that the first character in a string variable, say strCharacter, is not a space and if it is to delete it? Only the first character cannot be a space and I do not want to delete spaces other than just the first character.

    Thanks!

  2. #2
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Deletes Space in Variable (Word VBA)

    You can do this in one hit using:

    MyString = LTrim(MyString)

    LTrim, RTrim, and Trim Functions
    Returns a Variant (String) containing a copy of a specified string without leading spaces (LTrim), trailing spaces (RTrim), or both leading and trailing spaces (Trim).


    Alan

  3. #3
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Park City, Utah
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Deletes Space in Variable (Word VBA)

    Thank you, Alan!

Posting Permissions

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