Remove Consecutive Spaces

Hi,

Is there a way I can change the following code so that when the user enters ‘Bill Clinton’, the agent will replace it with ‘Bill%Clinton’.

The following will replace each space found with ‘%’ and the SQL will not recognise the query, when it’s ‘Bill%%Clinton’. I’ve just starting using LotusScript, so I’m not very familiar with how to use the commands in it.

Dim sName As String, chkSpc As String, posSpc As Long

sName = Trim(doc.SearchName(0))

chkSpc$ = " "

posSpc = Instr(sName, chkSpc)



If posSpc <> 0 Then

	Mid$(sName, posSpc) = "%"

End If

Subject: Remove Consecutive Spaces

Hi

Try

sName = FUlltrim(doc.SearchName(0))

chkSpc$=" "

posSpc = Instr(sName,chkSpc)

While possSpc <> 0

Mid$(sName,posSpc) = “%”

possSpc = Instr(sName,chkSpc)

Wend

FullTrim eliminates duplicate, trailing and leading whitespace.

The while loop checks for the existance of more than one space in the name. E.g. ‘Joe de Bloggs’ becomes ‘Joe%de%Bloggs’

HTH

cheers

andyG

Subject: RE: Remove Consecutive Spaces

Thanks!

It works beautifully!