Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CHR (13) and strings 1

Status
Not open for further replies.

DougAtAvalon

Programmer
Jan 29, 2001
99
US
How do I bring in the carrage returns for a string function

If I have a string:

"fffff
GGG"

And I set that to a variable, then use SQL to put it in a field.

So I world use "ffff" & chr (13) & "ggg"

How do I find the carriage returns in the string variable???

-Doug
 
Hi Doug,
This is a piece of code that strips VbCrlf from code. Play with it a little and you could modify it as required depending on your needs.

Function ZIPPP()
CrLfStripper("ffff" & vbCrLf & "GGG")
'CrLfStripper ("TherearenoCRLFsinthisstring")
End Function
'Above is just to fire the next from one module so you can watch while you go! Click on Zippp and hit the run > button.

Function CrLfStripper(StrText As String) As String
Dim IntLgth As Integer, IntRemain As Integer, IntPos As Integer
IntLgth = Len(StrText)
IntRemain = Len(StrText)
IntPos = 1
CrLfStripper = StrText
Do Until IntRemain = 0 'keep decreasing
IntPos = InStr(IntPos, CrLfStripper, vbCrLf)
If IntPos <> 0 Then 'found one
CrLfStripper = Left(StrText, IntPos - 1) & Mid(StrText, IntPos + 2)
Else
GoTo AMessage
End If
IntRemain = IntLgth - IntPos
Loop

AMessage:
MsgBox StrText & &quot; is now &quot; & CrLfStripper & &quot;!&quot;, vbInformation, &quot;I am happy...&quot;
End Function

Hope this is what you're after, Gord
ghubbell@total.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top