vbCrLf 
Author Message
 vbCrLf

How can I find a vbCrLf in a string of Text?

For Example:

a string of text includes:

123 My Address
3rd Floor

Betrween the 123 My Address and 3rd Floor is a vbCrLf.

Thanks in advance!!!



Fri, 22 Apr 2005 22:52:50 GMT  
 vbCrLf
InStr (search from start) or InStrRev (search from end)
'=========
Private Sub Form_Load()
   Dim MyStr As String
   Dim iPos As Integer

   MyStr = "123 My Address" & vbCrLf & "3rd Floor"
   iPos = InStr(1, MyStr, vbCrLf)
   If iPos > 0 Then
      MsgBox "A vbCrLf can be found starting at location " & iPos
   End If

End Sub
'=========

--
Ken Halter - MS-MVP-VB - Please keep it in the groups..
http://www.vbsight.com - http://www.vbsight.com/MultiColumn.htm
http://www.vbsight.com/TBGDialogCTL.htm



Quote:
> How can I find a vbCrLf in a string of Text?

> For Example:

> a string of text includes:

> 123 My Address
> 3rd Floor

> Betrween the 123 My Address and 3rd Floor is a vbCrLf.

> Thanks in advance!!!



Fri, 22 Apr 2005 23:09:08 GMT  
 vbCrLf
Dim Pos as long
pos = instr(MyText, vbcrlf)



Quote:
> How can I find a vbCrLf in a string of Text?

> For Example:

> a string of text includes:

> 123 My Address
> 3rd Floor

> Betrween the 123 My Address and 3rd Floor is a vbCrLf.

> Thanks in advance!!!



Fri, 22 Apr 2005 23:12:17 GMT  
 vbCrLf


Quote:
> How can I find a vbCrLf in a string of Text?

> For Example:

> a string of text includes:

> 123 My Address
> 3rd Floor

> Betrween the 123 My Address and 3rd Floor is a vbCrLf.

> Thanks in advance!!!

You can use the InStr function to locate the vbCrLf (depending on what
you plan to do with the vbCrLf after you locate it, remember that vbCrLf
is a two-character string).

Print "Newline occurs at Char #" & InStr(TextString, vbCrLf)

If you are asking this question because you want to eliminate the
newline character sequence (say, replace it with a blank space so that
you have one line of text at the end instead of two or more), you can
bypass the above and use VB6's Replace function directly.

OneLine = Replace$(TwoLineString, vbCrLf, " ")

If you tell us what you are trying to do when you post a specific
question, sometimes we might be able to offer alternatives you might not
have considered. The above is my attempted guess at why you might be
asking the question that you did.

Rick - MVP



Fri, 22 Apr 2005 23:10:38 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. vbcrlf or vbCrLf

2. vbCrLf after attachment - (not '.Body')

3. vbCrLf - what is it?

4. vbcrlf

5. Embedded vbLF in message body is converted to vbCRLf

6. Squares using vbCrLf or Chr(13)

7. Stripping vbCrLf from strings

8. problem adding vbCrLf to FormField

9. When vbCr and when vbCrLf?

10. vbcrlf

11. Word XP Unprintable vbCrLF

12. Splitting on vbCRLF

 

 
Powered by phpBB® Forum Software