473,387 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

truncate to nearest word

i have written code to do the following task ...

* truncate a string to the nearest word so that the result string is less
than a certain length

.... but i am wondering the if .net class lib has built-in functionality to
do this and similar tasks ... ?

Nov 20 '05 #1
3 1638
Hi John,

You'd think so - two other people have wanted the same routine in the last
month.- but string handling for text editing is only so good.

It's there in drawing terms - DrawString can fit a string within a given
rectangle, splitting the text as required.

You can fiddle it using a RichTextBox- use a fixed-width font and set the
rtb width so big. Then assign your string to the Text property and read the
result back out from the Lines() array.

But simple plain, string routines ? Nope!

What else did you have in mind?

Regards,
Fergus

Nov 20 '05 #2
Cor
John

When I see your question I don't know why but I have to think on the "Trim"
function.

It removes the spaces before and after a string.

Cor
* truncate a string to the nearest word so that the result string is less
than a certain length

... but i am wondering the if .net class lib has built-in functionality to
do this and similar tasks ... ?

Nov 20 '05 #3
Hi Fergus.

I am trying to fit within a rectangle ... but some lines need to wrap (to 2
or 3 lines) and some lines of text need to strictly truncate.

Typical addresee block that needs to fit in the see-through window of an
envelope. I wrote all the code to do it, but it was completely custom code.
I thought maybe something useful was built-into the class lib.

"Fergus Cooney" <fi*****@post.com> wrote in message
news:e8**************@tk2msftngp13.phx.gbl...
Hi John,

You'd think so - two other people have wanted the same routine in the last month.- but string handling for text editing is only so good.

It's there in drawing terms - DrawString can fit a string within a given rectangle, splitting the text as required.

You can fiddle it using a RichTextBox- use a fixed-width font and set the rtb width so big. Then assign your string to the Text property and read the result back out from the Lines() array.

But simple plain, string routines ? Nope!

What else did you have in mind?

Regards,
Fergus

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: John Hunter | last post by:
I have a list of two tuples containing x and y coord (x0, y0) (x1, y1) ... (xn, yn) Given a new point x,y, I would like to find the point in the list closest to x,y. I have to do this a...
3
by: martin | last post by:
Hi, We have a heavily used production server and a table which logs every hit on a web site. This table has grown large over time and we want to clear it down as efficiently as possible. We would...
2
by: nkunapa | last post by:
Hi: Is there a way in XPATH to find the nearest node of the node in context with a certain attribute value. Here is my problem. I have the following XML and I am trying to add all the nodes with...
3
by: LineVoltageHalogen | last post by:
Greeting All, I have a stored proc that dynamically truncates all the tables in my databases. I use a cursor and some dynamic sql for this: ...... create cursor Loop through sysobjects and...
1
by: New MSSQL DBA | last post by:
I have recently been assigned to take over several MSSQL environments and found some of the existing practice confusing. As most of my previous experiences are on Oracle and Unix platform so would...
2
by: rdraider | last post by:
Hi, I am trying to create a script that deletes transaction tables and leaves master data like customer, vendors, inventory items, etc. How can I use TRUNCATE TABLE with an Exists? My problem is...
9
by: Sumanth | last post by:
Are there any implementations of truncate in db2. Is it going to be implemented in the future? Is there an alternate way of doing a truncate of a table that has a high record count without using...
2
by: Stimp | last post by:
Hi all, Having a bit of a headache trying to do this. I want to create a string with a total length of 160 characters. The first few characters must always be in the string.. say around 45...
10
by: Troels Arvin | last post by:
Hello, Until this date, I believed that DB2 has no TRUNCATE TABLE command. But then I came across...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.