remove portion of string

  • Thread starter Thread starter K
  • Start date Start date
K

K

I need a function that will return a string from a passed string value. This
is an example of the passed value:


12/10/2007 10:51:04 AM kwithrow Open Call
==================================
This is a test for #1.
12/10/2007 10:53:10 AM kwithrow Open Call
==================================
This is #2 Test.
12/10/2007 11:45:15 AM kwithrow Open Call
==========

I need to have returned:

This is #2 Test.
12/10/2007 11:45:15 AM kwithrow Open Call


The string is never the same, but will always be seperated by =. I need the
last section of string between the last set of = and the second to the last
set of =.

TIA,

Kim
 
K said:
I need a function that will return a string from a passed string value.
This
is an example of the passed value:


12/10/2007 10:51:04 AM kwithrow Open Call
==================================
This is a test for #1.
12/10/2007 10:53:10 AM kwithrow Open Call
==================================
This is #2 Test.
12/10/2007 11:45:15 AM kwithrow Open Call
==========

I need to have returned:

This is #2 Test.
12/10/2007 11:45:15 AM kwithrow Open Call


The string is never the same, but will always be seperated by =. I need
the
last section of string between the last set of = and the second to the
last
set of =.

TIA,

Kim

Here's one way:

Dim a As Variant, strResult As String

a = Split(IncomingString, vbCrLf)

The variable a is then an array containing:

a(0): 12/10/2007 10:51:04 AM kwithrow Open Call
a(1): ==================================
a(2): This is a test for #1.
a(3): 12/10/2007 10:53:10 AM kwithrow Open Call
a(4): ==================================
a(5): This is #2 Test.
a(6): 12/10/2007 11:45:15 AM kwithrow Open Call
a(7): ==========

So we can now say:

strResult = a(5) & vbCrLf & a(6)
 
Except that relies on you knowing how may lines there are in total and how
many lines there are in the section of text that is desired.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
John Spencer said:
Except that relies on you knowing how may lines there are in total and how
many lines there are in the section of text that is desired.

Yes. I'm waiting for the OP to clarify whether this is the case, then if so,
take it from there.

(I should have said so, I suppose)
 
Back
Top