carraigew retu

CM670

Registered User.
Local time
Today, 13:18
Joined
Oct 19, 2012
Messages
10
Does anyone know how i can replace a carriage return with a space? i am using VB5

For eg if the user enters
Address1
Address2
Address3

i want it to print as

Address1 Address 2 Address 3




I have tried this and it wont work. Does anyone have any ideas?

psFreeText = ""



For picount = 1 To Len(txtFreeText.Text)

If Mid(txtFreeText.Text, picount, 1) = vbCr Or Mid(txtFreeText.Text, picount, 1) = vbLf Then

psFreeText = psFreeText + " "

Else

psFreeText = psFreeText + Mid(txtFreeText.Text, picount, 1)

End If



Next picount




Next picount
 
Try this:
Code:
'declare variable
Dim psFreeText as String
 
'if the form is unboud, set focus to the control so value can be read
me.txtFreeText.Text.setfocus
 
psFreeText = Replace(me.txtFreeText.Text, Chr(13) & Chr(10), " ")

this should assign a string to the "psFreeText" variable containing:
"Address1 Address2 Address3"
 
VB5 does not have the replace function. Is there another way of doing this?
 
You can simulate the Replace Function.. Try the code in the link.. See if it will help..
 

Users who are viewing this thread

Back
Top Bottom