Inserting brakes in a long text

This code show how to insert brakes in long text..



public string insertBreak(string strMessage, int cdeIndex)
{
String jobname = strMessage;
if (jobname.Length > cdeIndex)
{
int k = cdeIndex;
int j = (jobname.Length / k);


for (int i = 0; i < j; i++)
{
int cdeDifference = 0;
int cdeFindspace = 0;
if ((k + 10) < jobname.Length)
{
cdeFindspace = jobname.IndexOf(" ", k - 2, 10);
}
else { cdeFindspace = -1; }
if (cdeFindspace != -1)
{
cdeDifference = cdeFindspace - k;
k = cdeFindspace;

}
jobname = jobname.Insert(k, "<br />");
if ((k + (k + 6)) < jobname.Length)
{
k = k + (k + 6) + (cdeDifference);
}
else
{
break;
}
}
}
return jobname;
}


Reference: INSERTING BRAKS IN A LONG TEXT


Comments

Author: Pradeep Iyer29 Oct 2008 Member Level: Gold   Points : 0

hi prasanth,

nice function

regards,
pradeep



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: