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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you find a Hard return in text.

Status
Not open for further replies.

Brawn

Programmer
Jul 5, 2001
73
0
0
CA
This ...

if mid(string,i,1) = vbCrLf then
'do something
end if

... does not work.
[neutral]

Brawn

"My mind is my Shrine,
and my body the Temple around it."

-The difference between genius and stupidity is that genius has its limits-
 
Try

if mid(string,i,1) = chr$(13) then
'do something
end if
Craig, mailto:sander@cogeco.ca

Remember not to name the Lambs...
It only makes the chops harder to swallow
 
Now that I think about it. It looks to me like your looping through a text box to find the return characters. There is a better way to do this.

Instead of [tt]
For i = 1 to len(strString)
If Mid(strString,i,1) = Chr$(13) Then
'do something
End If
Next i
[/tt]
You could use this [tt]
i = InStr(strString, 1, Chr$(13))
[/tt]
Craig, mailto:sander@cogeco.ca

Remember not to name the Lambs...
It only makes the chops harder to swallow
 
awesome!! Brawn

"My mind is my Shrine,
and my body the Temple around it."

-The difference between genius and stupidity is that genius has its limits-
 
wait a minute,

what if there is more than one hard return in a string
you coudn't still use this could u ?
Code:
i = InStr(strString, 1, Chr$(13))

i found that this works to
Code:
For i = 1 to len(strString)
    If Asc(Mid(strString,i,1)) = 13 Then
        'do something
    End If
Next i
Brawn

"My mind is my Shrine,
and my body the Temple around it."

-The difference between genius and stupidity is that genius has its limits-
 
more efficient would be the following:

i = instr(1, strString, chr(13))
Do While (i > 0)
<do somehting>
i = instr(i+1, strstring, chr(13))
Loop
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top