Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Location
    South Africa
    Posts
    8

    Lightbulb Unanswered: Cancel String spaces

    How to cancel spaces in a string e.g Lets say x="VB How To Program", How to change it to be like "VBHowToProgram"

    Please help, its urgent.

  2. #2
    Join Date
    Nov 2002
    Posts
    7

    Code

    In VB, I use this:


    ************ Create a function like this *********************

    Public Function CleanNumber(IDNumber)
    Dim CleanNumber1 As Integer
    Dim CleanNumber2 As String

    CleanNumber2 = IDNumber
    CleanNumberStart:

    'Remove any spaces or dashes from an account or meter number.
    If InStr(CleanNumber2, " ") Then
    CleanNumber1 = InStr(CleanNumber2, " ")
    CleanNumber2 = Mid(CleanNumber2, 1, CleanNumber1 - 1) & Mid(CleanNumber2, CleanNumber1 + 1, (Len(CleanNumber2) - CleanNumber1))
    GoTo CleanNumberStart
    End If
    If InStr(CleanNumber2, "-") Then
    CleanNumber1 = InStr(CleanNumber2, "-")
    CleanNumber2 = Mid(CleanNumber2, 1, CleanNumber1 - 1) & Mid(CleanNumber2, CleanNumber1 + 1, (Len(CleanNumber2) - CleanNumber1))
    GoTo CleanNumberStart
    End If

    CleanNumber = CleanNumber2

    End Function

    ************ Then, instead of ***********************
    x = YourStringField

    ************ Use *********************************
    x = CleanNumber(YourStringField)

  3. #3
    Join Date
    Feb 2002
    Posts
    2,232
    x=Replace("VB How To Program"," ","")

Posting Permissions

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