473,385 Members | 1,292 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,385 software developers and data experts.

String Manipulation

I'm trying to build an app that populates a word form. The problem
I've got is when the user types more data than the field will hold, I
need to take the excess and dump it onto a continuation page. The
string I'm dealing with is an undetermined length and can have several
carriage returns in it. Each line can be 75 characters long, so my
thinking was to go through the string until I get to a CR or the first
space before 75 characters and call that a line and put in a CR if
necessary.

Any thoughts on the best way to do this. I thought I had all laid out
in my mind, but you now how that goes.

Thanks

Kirk
Nov 20 '05 #1
5 1296
Hi Kirk,

Some questions.

1 Is there a limit for the number of characters in the entire field?
2 Is there a limit on the number of lines per field?
3 Is there a limit on the number of characters per line?
4 Do you want to preserve lines or is it ok, as you seem to be
suggesting, to split a line.
5 If splitting is ok, are we talking word-wrap where the excess on one
line is joined to the text on the next?
6 Is there the same limitation on continuation pages, meaning that
they'll need to be split too?

Regards,
Fergus
Nov 20 '05 #2
1. There is no limit on the amount text.
2. Yep. 10 lines or so. Regardless of the count, I'm going to want to
keep track of how many lines so I can change if necessary.
3. Because it's a word document, I guess there's technically not a limit
on the number of characters per line, but my thinking is to put a CR at
the first space prior to 75.
4. Lines don't necessarily have to be preserved. Like I mentioned above,
I'm thinking about putting a CR at the end of everyline whether it's
going to wrap or not.
5. See above.
6. Continuation pages will be just like a "normal" document, word wrap
and all.

Kirk
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3
Hi Kirk,

Just so that I understand, is this a correct abstract restatement of your
problem ?

Given a single string of arbitrary length, optionally containing
line-breaks, break this up into groups of lines (initially 10 per group but
this is arbitrary). Each line will be less than or equal to an arbitrary
maximum length (initially 75 characters) and broken at the nearest space to
that limit.

If so, one method would be to create the lines one at a time in an
ArrayList. Leave the original string untouched and just take sections out as
required (ie, don't remove the line and start at the beginning but keep an
index into the string. This will save on string allocations and the copying of
text, expecially if the text is large.) Then you can apportion the lines to
your field and continuation pages as required in a second phase.

Is this what you had in mind? Or were you hoiping for more choices, or
more details, perhaps, on the splitting, etc?

Regards,
Fergus
Nov 20 '05 #4
Fergus,

You hit the nail right on the head.

Kirk


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #5

This seems to work:

Dim thisColl As Queue = New Queue()
Dim newString As String
Try
Do While inputStr.Length > 0
If inputStr.Substring(0,
inputStr.IndexOf(Chr(13))).Length < 70 _
Or inputStr.Substring(0,
inputStr.IndexOf(Microsoft.VisualBasic.Right(input Str, 1))).Length < 70
_
Then
newString = inputStr.Substring(0,
inputStr.IndexOf(Chr(13)) + 1)
Else
newString = inputStr.Substring(0, 70)
End If

thisColl.Enqueue(newString)
inputStr = inputStr.Remove(0, newString.Length)
Loop
Catch exc As Exception
thisColl.Enqueue(inputStr)
End Try
Dim colCtr As Integer = thisColl.Count - 4
Do While thisColl.Count > colCtr
newString = newString & thisColl.Dequeue
Loop

Return newString

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #6

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

Similar topics

4
by: Dim | last post by:
I found that C# has some buggy ways to process string across methods. I have a class with on global string var and a method where i add / remove from this string Consider it a buffer... with some...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
29
by: zoro | last post by:
Hi, I am new to C#, coming from Delphi. In Delphi, I am using a 3rd party string handling library that includes some very useful string functions, in particular I'm interested in BEFORE (return...
4
by: WaterWalk | last post by:
Hello, I'm currently learning string manipulation. I'm curious about what is the favored way for string manipulation in C, expecially when strings contain non-ASCII characters. For example, if...
10
by: micklee74 | last post by:
hi if i have a some lines like this a ) "here is first string" b ) "here is string2" c ) "here is string3" When i specify i only want to print the lines that contains "string" ie the first...
5
by: Niyazi | last post by:
Hi, Does anyone knows any good code for string manipulation similar to RegularExpresion? I might get a value as string in a different format. Example: 20/02/2006 or 20,02,2006 or ...
3
by: crprajan | last post by:
String Manipulation: Given a string like “This is a string”, I want to remove all single characters( alphabets and numerals) like (a, b, 1, 2, .. ) . So the output of the string will be “This is...
7
Frinavale
by: Frinavale | last post by:
I currently have a .NET application that has an object which passes a string (a connection string) as a parameter to another object that does database manipulation. This string isn't stored...
3
by: frankeljw | last post by:
I have 2 Java strings 1st String is a series of names, colons, and numbers ie) Name1:13:Name2:4526:Name3:789:Name4:3729:Name5:6:Name6:44 2nd String is a name ie) Name2 I need to get the...
22
by: mann_mathann | last post by:
can anyone tell me a solution: i cannot use the features in standard c++ string classgh i included the string.h file but still its not working.
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.