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

Keeping words together?

Status
Not open for further replies.

johany

Programmer
Joined
Apr 16, 2002
Messages
2
Location
SE
Ok,
I've retrived some really long text from a table. Now I'd like to split it up into two columns. I replace some stuff and then:
For col1: left(string,600)
For col2: left(string,600)

My problem is that words get split up i.e
in col1 it sais: "I have a big blac"
and in col2: "k dog."

Is there som good way to solve this?

Thanks for your help!

/johan
 
Give something like this a try.
maybe someone else can clean it up


' search for blank space
SearchChar = " "

SearchString = "what ever the text string is"

'position of blank space in string after 600
Pos = InStr(1, SearchString, SearchChar, 1)

'text before blank space
strText1 = Left(SearchString, Pos)

'length of text
tLen = Len(strText1)

strText2 = Right(strText1, (tLen))

For Col 1: strText1
For Col 2: strText2

hope it helps,
Rick
 
Oops, correction

'position of blank space in string after 600
Pos = InStr([COLOR=#ff000]600[/color], SearchString, SearchChar, 1)
 
Thanks!
That really helped.

This way it works very good:

'Get a big chunk of text from a db and replace the
'linefeeds with <br>
SearchString = replace(rsBook(&quot;str_Desc&quot;), VbCrlf, &quot;<br>&quot;)

'search for blank space
SearchChar = &quot; &quot;

'position of blank space in string after 600
Pos = InStr(600, SearchString, SearchChar, 1)

'text before blank space
strText1 = Left(SearchString, Pos)

'length of text
tLen = Len(strText1)

strText2 = mid(SearchString, tLen)

Response.write strText1

Response.write strText2

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top