[AccessD] Parsing String

Mitsules, Mark Mark.Mitsules at ngc.com
Fri Jan 14 07:47:28 CST 2005


Thanks for the suggestions gentlemen.  With your help, here is what I ended
up with...

Select Case Len(![DrawingTitle])
   Case Is > 40
      lngHalfTitle = Len(![DrawingTitle]) / 2
      strTitle = ![DrawingTitle]
      lngCutOff = InStrRev(strTitle, " ", lngHalfTitle)
      strTitle1 = Trim(Left(strTitle, lngCutOff))
      strTitle2 = Trim(Right(strTitle, Len(strTitle) - lngCutOff))


Mark


-----Original Message-----
From: Reuben Cummings [mailto:reuben at gfconsultants.com] 
Sent: Thursday, January 13, 2005 4:09 PM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] Parsing String


lngCutOff = InStrrev(strWhatever," ",53)
strFirstLine = trim(left(strWhatever,lngCutOff))
strSecondLine = trim(right(strWhatever,len(strWhatever)-lngCutOff))

Reuben Cummings
GFC, LLC
phone: 812.523.1017
email: reuben at gfconsultants.com


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Mitsules, Mark
Sent: Thursday, January 13, 2005 3:42 PM
To: [AccessD]
Subject: [AccessD] Parsing String


Group,

I have a large recordset of strings that need to be split up by length,
maximum of 53 characters per line, not to exceed 2 lines.  The issue I am
struggling with is maintaining logical word breaks.  For instance, here is
an example string (watch for line wrap):

VENTILATION CONNECTION UNDER 1ST, 2ND & 3RD PLATFORM, FR 37-39 - HANGER
DETAILS MANUFACTURING

Can anyone suggest a good routine to accomplish this?  Here are my first
thoughts...  I would like to take any line over 40 characters and split it
into 2 lines, so the pseudocode might be something like:

If len(strTitle) > 40, Then
 starting point is at the halfway point
 If at a space, then
  make the break here
 Else
  count number of characters forward to a space
  count number of characters backward to a space
  make the break at the lower of the two
 End If
End If


Thanks for any suggestions.


Mark
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list