Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having problems with L and or R trim and more

Status
Not open for further replies.

TonyU

Technical User
Feb 14, 2001
1,317
US
[tt]Hello all, I'm currently working on a project and I'm having problems displaying a specific data field from my database using RTrim and or LTrim

<%= RTrim((views.Fields.Item(&quot;topic&quot;).Value)) %>


this &quot;Topic&quot; field can and I know it will get long but I only want to display part of it. Shouldn't my code above do the trick?? or am I wrong? I would like to show if the topic reads &quot;We will be having a meeting....&quot;

Thanks in advance all.
[tt]&quot;A Successful man is one who can build a firm foundation with the bricks that others throw at him&quot;[/tt]
[noevil]
 
confused!
the trim function only gets rid of the leading and trailing spaces. is that all you are doing? or do you want to take only a portion of the value and display it. if so do
Dim MyString, LeftString
MyString = &quot;VBSCript&quot;
LeftString = Left(MyString, 3) ' LeftString contains &quot;VBS&quot;.
I help at your own risk, if I brake it sorry! But if I fixed it, let me know.[thumbsup2]
admin@onpntwebdesigns.com
 
to be a little more specific.
if <%= views.Fields.Item(&quot;topic&quot;) %> contains &quot;We will be having a meeting&quot;
and you did

dim topic
topic = views.Fields.Item(&quot;topic&quot;).Value
Right(topic, 2) you would return &quot;We&quot; I help at your own risk, if I brake it sorry! But if I fixed it, let me know.[thumbsup2]
admin@onpntwebdesigns.com
 
[tt]Duh!
I'm confused also by my questions

You are right, I want to do what you suggested. The next quetions is, where do I place your code in order of it to work?
[tt]&quot;A Successful man is one who can build a firm foundation with the bricks that others throw at him&quot;[/tt]
[noevil]
 
All that RTrim will do is remove spaces from the right side of the string.

Maybe you are thinking of something more like this:

<%=Mid(views.Fields.Item(&quot;topic&quot;).Value, 30) & &quot;...&quot; %>

This will truncate your string at 30 characters and add the ... at the end. When using the Mid function, though, always check to make sure your string has a value.

<%
dim strDisplay
strDisplay = views.Fields.Item(&quot;topic&quot;).Value

if Len(strDisplay < 30 then
Response.write strDisplay
else
Response.write Mid(views.Fields.Item(&quot;topic&quot;).Value, 30) & &quot;...&quot;
end if

%>
 
[tt]I'm getting this error
JuanitaC

if Len(strDisplay < 15 then
-----------------------^

I changed the 30 to 15
[tt]&quot;A Successful man is one who can build a firm foundation with the bricks that others throw at him&quot;[/tt]
[noevil]
 
if Len(strDisplay < 15) then

missed the )
I help at your own risk, if I brake it sorry! But if I fixed it, let me know.[thumbsup2]
admin@onpntwebdesigns.com
 
[tt]Sorry to keep bothering you but now, I get this

Microsoft VBScript runtime error '800a000d'

Type mismatch: '[string: &quot;I'm testing this new&quot;]'

/site/folder/myviews.asp, line 190

Line 190:
if Len(strDisplay < 15) then






[tt]&quot;A Successful man is one who can build a firm foundation with the bricks that others throw at him&quot;[/tt]
[noevil]
 
Hi

that statement has to be like this

if Len(strDisplay) < 15) then

Sunil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top