manipulation of a long string

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there,

I get a string from a recordset, with is delemitered by the | character for
the different values.

The string looks like this: Peter|Pan|Donald|Duck

Now I would like to each result seperately.

strDetails = rs.GetString(ADODB.StringFormatEnum.adClipString
,1,"|",",",null);
LblFax.Text = getTheDetails(0);

I wrote the getTheDetails function to get the strings.

public string getTheDetails(int intIndex)
{
int intEnd = strDetails.IndexOf("|", intIndex, strCurrent.Length);
strTmpDet = strDetails.Substring(intEnd);
return strTmpDet;
}

It doesn't work properly. Where do I set from which delemiter to begin. Or
is this not possible at all?

Thanks for your help.

Cheers

Chris
 
hi chris,
didn't look at your code but suggest you use string.Split('|');
this will returns a string[] tokens = mystring..Split('|');

foreach (string token in tokens)
{
// use ur token
}
 
Thanks Brian. It works fine.

Cheers

Chris

Brian Keating said:
hi chris,
didn't look at your code but suggest you use string.Split('|');
this will returns a string[] tokens = mystring..Split('|');

foreach (string token in tokens)
{
// use ur token
}

chris said:
Hi there,

I get a string from a recordset, with is delemitered by the | character for
the different values.

The string looks like this: Peter|Pan|Donald|Duck

Now I would like to each result seperately.

strDetails = rs.GetString(ADODB.StringFormatEnum.adClipString
,1,"|",",",null);
LblFax.Text = getTheDetails(0);

I wrote the getTheDetails function to get the strings.

public string getTheDetails(int intIndex)
{
int intEnd = strDetails.IndexOf("|", intIndex, strCurrent.Length);
strTmpDet = strDetails.Substring(intEnd);
return strTmpDet;
}

It doesn't work properly. Where do I set from which delemiter to begin. Or
is this not possible at all?

Thanks for your help.

Cheers

Chris
 
Back
Top