Results 1 to 3 of 3

Thread: Replacin Spaces in a string

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2001
    Posts
    2

    Replacin Spaces in a string

    I am trying to do a database search on a name that I get from a vb text box. However I'm allowing users to put in a first and last name. In SQL I want the query to include '%John%Doe%'. How do I go about removing the space between John and Doe, and inserting the %?

  2. #2
    jim mcnamara
    Guest
    Code:
        sName = "   John  Doe  "
    
    
    Function FixIt(str as String) as String
        Dim strName as string
        strName = str
        Do While Instr(strName, "  ") > 0
          strname = Replace(strName,"  "," ")
        Loop
        strName = Replace(strName," ","%")
        FixIt = strName
    End Function

  3. #3
    rickm
    Guest

    Re: Replacin Spaces in a string

    Originally posted by SuperChick
    I am trying to do a database search on a name that I get from a vb text box. However I'm allowing users to put in a first and last name. In SQL I want the query to include '%John%Doe%'. How do I go about removing the space between John and Doe, and inserting the %?
    using vb6:

    String = "%" & replace("John Doe"," ","%") & "%"

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