Cut of String at Carriage Return

J

jokobe

I have a string like this:
strmyautor = mid(strclipboard, pos1, pos2)

Within strmyautor is a linefeed or carriage return and I want to cut of the
string at the linefeed or carriage return.

Any helpfull hints?

Thanks in advance..

jokobe
 
S

Stuart McCall

jokobe said:
I have a string like this:
strmyautor = mid(strclipboard, pos1, pos2)

Within strmyautor is a linefeed or carriage return and I want to cut of
the
string at the linefeed or carriage return.

Any helpfull hints?

Thanks in advance..

jokobe

Dim p As Long

p = Instr(1, strmyautor, vbCrLf)
If p > 0 Then
strmyautor = Left(strmyautor, p - 1)
Else
p = Instr(1, strmyautor, vbLf)
If p > 0 Then
strmyautor = Left(strmyautor, p - 1)
Else
p = Instr(1, strmyautor, vbCr)
If p > 0 Then
strmyautor = Left(strmyautor, p - 1)
End If
End If
End If
 
J

jokobe

Stuart,
thanks for your answer. I managed to solve the problem already in the way
you described, but I expected to function like LEFT, RIGHT or MID.

Anyhow,

thanks again....

jokobe
 
F

fredg

I have a string like this:
strmyautor = mid(strclipboard, pos1, pos2)

Within strmyautor is a linefeed or carriage return and I want to cut of the
string at the linefeed or carriage return.

Any helpfull hints?

Thanks in advance..

jokobe

In Access, a new line is a carriage return and a line feed together
(in that order). Is that what you wish to use to cut off the string?

NewString = Left(strmyautor,InStr(strmyautor,chr(13) & chr(10))-1)
 

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