Cut of String at Carriage Return

  • Thread starter Thread starter jokobe
  • Start date Start date
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
 
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
 
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
 
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)
 
Back
Top