Strange StringTrim behavior

  • Thread starter Thread starter Raymond Andreassen
  • Start date Start date
R

Raymond Andreassen

After some time of debugging one of our apps, I started a witchhunt on the
StringTrim function.

basicly the error can be reduced down to the following:

It started with testing of the following text
StringTrim( "HEGE HERMANSN", 15) gives "HEGE HERMANSN" string
(note 2 spaces)

while
StringTrim( "HEGE HERMANSEN", 15) gives 'StringTrim( "HEGE HERMANSEN",
15)' threw an exception of type 'System.ArgumentOutOfRangeException' string
{System.ArgumentOutOfRangeException}

The testing followed
StringTrim( "123456789012345", 15) gives 'StringTrim( "123456789012345",
15)' threw an exception of type 'System.ArgumentOutOfRangeException' string
{System.ArgumentOutOfRangeException}

while
StringTrim( "1234567890123456", 15) gives "234567890123456" string

and
StringTrim( "12345678901234", 15) gives "12345678901234" string


In short: If the text equals in length with the trimming length, StringTrim
will cast an exception.


Can someone please inform me weather this is a known behavior, or it is an
error in stringtrim function?
Is there a workaround?
 
Raymond,
After some time of debugging one of our apps, I started a witchhunt on the
StringTrim function.

I'm not familiar with any StringTrim function. Where is it defined?


Mattias
 
Raymond Andreassen said:
After some time of debugging one of our apps, I started a witchhunt on the
StringTrim function.

There's no StringTrim method in .NET as far as I've seen, and
String.Trim doesn't take a string and an integer as parameters.

Could you tell us exactly what you're using?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top