Limit the characters returned by a string?

liunx

Guest
Hi,

Does anyone know how to limit the characters returned by a string?

So, I have a string that will be of variable length, I want to limit the number of characters to 150.

This string is being created dynamically in .NET and therefore cannot be limited at the SQL back end.

Any ideas? :confused:

Thanks.

AJNCheck the string length, if it is greater than your max then use the substring to retrieve only the max length allowed.

EricThanks for that. Hate to sound stupid, but where/how do I set the max length and how do I retrieve the max length allowed?

Thanks again.

AJNWhere is this max length coming from? Sounded like you already knew the max length you wanted.

EricSorry if I'm being vague.

I am unsure of the syntax for this.

I have a string called 'strSearchSummaryLabel' which I want to limit to 150 characters at the most. I would like to hard-code the max limit if possible.

As a further explanation, this string will populate a label called 'lblSearchCriteria'. As the string is dynamically created by the user, I need to limit the length in order to preserve space and the shape of my website.

I know how to limit strings in SQL, but not in .NET unfortunately!

Thanks.

AJNSomoething like this:

If strValue.length > 150 Then
strValue =- strValue.Substring(0,150)
End If

EricAha! Easy when you know how!

Thank you. :)

AJN
 
Back
Top