Re: trimend problem (remove trailing period) by Bob
Bob
Thu Jan 31 09:38:55 CST 2008
RICK wrote:
> Why am I getting "object required" in the following?
Because:
1. unless you have changed the setting in IIS, the default server-side
scripting language is vbscript
2. you have not specified the server-side script language anywhere that
I can see so it should be defaulting to vbscript
3. you have a scalar variable (strauthor) that you are attempting to use
as if it was an object. Only objects have properties and methods. Unlike
javascript, in which everything is an object (yes, I know that's a
simplification), vbscript has scalar and object variables. Object
variables need to be initialized using the Set keyword. strauthor was
not initialized using Set, therefore you are getting the "object
required" error.
> How can I
> remove the period using trimend?
What is trimend? It's certainly not a builtin method that I have heard
of. The only reference to a TrimEnd method that I can find is in the
.Net documentation. Your code looks to me like classic (non-dotnet)
code, so either:
1. You have misread a book or some documentation somewhere that has led
you to believe that you could use a .Net method in classic ASP (you
can't), or
2. You have written a function called trimend that you have failed to
include in your page.
How to remove the period? There are many ways. Here is a non-regex one:
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
function TrimEnd (s)
dim length
length = len(s)
if length > 0 then
if Right(s,1) = "." then
s= Mid(s,1,length - 1)
end if
TrimEnd = s
else
TrimEnd = s
end if
end function
%>
> <html>
> <head>
> <title>Untitled Document</title>
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">
>
> <% strAuthor = "abc." %>
>
> </head>
>
> <body>
> <% response.write trimend(strauthor)%>
> </body>
> </html>
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.