Replace in text field

L

Les

On exit from a text box I need to check the text string and replace all the
spaces with an underscore. I have tried to work out the replace command but
without success.

My text box is names strMessage.

Can someone please give me the correct syntax for this

Thanks

Les
 
L

losmac

Sub testChanging(
MsgBox ChngSpc2Undscr("Bla, bla, bla"
End Su

Function ChngSpc2Undscr(ByVal sometext As String) As Strin
Dim pos As Lon

D
pos = InStr(pos + 1, sometext, " ", vbBinaryCompare
If pos > 0 Then Mid(sometext, pos, 1) = "_" 'replace space with underscor
Loop While pos >

ChngSpc2Undscr = sometex

End Functio
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top