thatelvis
asked on
how to join two functions
Hello,
I have this function below and it works great. how ever I also want to use the one below on the same variable how do I do it
<%
' this will crop a sentence
Function CropSentence(strText, intLength, strTrial)
If Len(strText) > intLength Then
CropSentence = Left(strText, intLength) & strTrial
Else
CropSentence = strText
End If
End Function
%>
<%= CropSentence((Recmostofuse r.Fields.I tem("count ry_usr").V alue), 10, "...") %>
-------------------------- ---------- ---------- ---------- ---------- --- above is used for cropping a sentence and works -------------------------- ------
below is for making the first letter of each word capital but i want to use that and the above but dont know how to use them both together.
<% function Proper(str)
Proper = ucase(left(str,1)) & lcase(right(str,len(str)-1 ))
end function
%>
all help greatly received.
kenny
I have this function below and it works great. how ever I also want to use the one below on the same variable how do I do it
<%
' this will crop a sentence
Function CropSentence(strText, intLength, strTrial)
If Len(strText) > intLength Then
CropSentence = Left(strText, intLength) & strTrial
Else
CropSentence = strText
End If
End Function
%>
<%= CropSentence((Recmostofuse
--------------------------
below is for making the first letter of each word capital but i want to use that and the above but dont know how to use them both together.
<% function Proper(str)
Proper = ucase(left(str,1)) & lcase(right(str,len(str)-1
end function
%>
all help greatly received.
kenny
ASKER
how can I apply both the CropSentence function and the Proper funcition to this
<%= ((Recmostofuser.Fields.Ite m("country _usr").Val ue), 10, "...") %>
<%= ((Recmostofuser.Fields.Ite
try this, i m not sure but it may work
<%
' this will crop a sentence
Function CropSentence(strText, intLength, strTrial)
If Len(strText) > intLength Then
CropSentence = Left(strText, intLength) & strTrial
Else
CropSentence = ucase(left(strText,1)) & lcase(right(strText,len(st rText)-1))
End If
End Function
%>
<%= ((Recmostofuser.Fields.Ite m("country _usr").Val ue), 10, "...") %>
<%
' this will crop a sentence
Function CropSentence(strText, intLength, strTrial)
If Len(strText) > intLength Then
CropSentence = Left(strText, intLength) & strTrial
Else
CropSentence = ucase(left(strText,1)) & lcase(right(strText,len(st
End If
End Function
%>
<%= ((Recmostofuser.Fields.Ite
ASKER
nope it didnt work,
let me try on this first, i wil get back 2 u.
<%
' this will crop a sentence
Function CropSentence(strText, intLength, strTrial)
If Len(strText) > intLength Then
CropSentence = Left(strText, intLength) & strTrial
Else
CropSentence = strText
End If
End Function
function Proper(str)
Proper = ucase(left(str,1)) & lcase(right(str,len(str)-1 ))
end function
dim arrText()
dim fullText, myText
myText=CropSentence((Recmo stofuser.F ields.Item ("country_ usr").Valu e), 10, "...")
arrText=myText.Split(" ")
for i=0 to arrText.Length-1
fullText=fullText & Proper(arrText(i) & " "
next
%>
' this will crop a sentence
Function CropSentence(strText, intLength, strTrial)
If Len(strText) > intLength Then
CropSentence = Left(strText, intLength) & strTrial
Else
CropSentence = strText
End If
End Function
function Proper(str)
Proper = ucase(left(str,1)) & lcase(right(str,len(str)-1
end function
dim arrText()
dim fullText, myText
myText=CropSentence((Recmo
arrText=myText.Split(" ")
for i=0 to arrText.Length-1
fullText=fullText & Proper(arrText(i) & " "
next
%>
<%
Function CropSentence(strText, intLength, strTrial)
If Len(strText) > intLength Then
CropSentence = Left(strText, intLength) & strTrial
Else
CropSentence = strText
End If
End Function
function Proper(str)
Proper = ucase(left(str,1)) & lcase(right(str,len(str)-1 ))
end function
for each element in split(CropSentence("ewtwet ery weryreyerwy ery er ywery er ywer", 20, "..."), " ")
xx = xx & proper(element) & " "
next
response.write xx
%>
How bout this =)
Function CropSentence(strText, intLength, strTrial)
If Len(strText) > intLength Then
CropSentence = Left(strText, intLength) & strTrial
Else
CropSentence = strText
End If
End Function
function Proper(str)
Proper = ucase(left(str,1)) & lcase(right(str,len(str)-1
end function
for each element in split(CropSentence("ewtwet
xx = xx & proper(element) & " "
next
response.write xx
%>
How bout this =)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
what I have below works for the use I want, thanks all for your help.
this will capitilise every word in a sentence.
<%
function proper(str)
proper = ""
aStr = split(str," ")
for i = 0 to ubound(aStr)
proper = proper & ucase(left(aStr(i),1)) & lcase(right(aStr(i),len(aS tr(i))-1)) & " "
next
proper = rtrim(proper)
end function
%>
<%= proper(CropSentence((Recmo stofuser.F ields.Item ("country_ usr").Valu e),10,"... ")) %>
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----
'this is for the first letter only and nothing else.
function Proper(str)
Proper = ucase(left(str,1)) & lcase(right(str,len(str)-1 ))
end function
<%=Proper(Reclistall.Field s.Item("fi rstname_us r").Value) %>
this will capitilise every word in a sentence.
<%
function proper(str)
proper = ""
aStr = split(str," ")
for i = 0 to ubound(aStr)
proper = proper & ucase(left(aStr(i),1)) & lcase(right(aStr(i),len(aS
next
proper = rtrim(proper)
end function
%>
<%= proper(CropSentence((Recmo
--------------------------
'this is for the first letter only and nothing else.
function Proper(str)
Proper = ucase(left(str,1)) & lcase(right(str,len(str)-1
end function
<%=Proper(Reclistall.Field
ASKER
<%
' this will crop a sentence
Function CropSentence(strText, intLength, strTrial)
If Len(strText) > intLength Then
CropSentence = Left(strText, intLength) & strTrial
Else
CropSentence = ucase(left(strText,1)) & lcase(right(strText,len(st rText)-1))
End If
End Function
%>
<% 'this will make the first word in each sentence capital
function proper(str)
proper = ""
aStr = split(str," ")
for i = 0 to ubound(aStr)
proper = proper & ucase(left(aStr(i),1)) & lcase(right(aStr(i),len(aS tr(i))-1)) & " "
next
proper = rtrim(proper)
end function
%>
above works briliant
' this will crop a sentence
Function CropSentence(strText, intLength, strTrial)
If Len(strText) > intLength Then
CropSentence = Left(strText, intLength) & strTrial
Else
CropSentence = ucase(left(strText,1)) & lcase(right(strText,len(st
End If
End Function
%>
<% 'this will make the first word in each sentence capital
function proper(str)
proper = ""
aStr = split(str," ")
for i = 0 to ubound(aStr)
proper = proper & ucase(left(aStr(i),1)) & lcase(right(aStr(i),len(aS
next
proper = rtrim(proper)
end function
%>
above works briliant
you are welcome.
sorry I put
for i=0 to arrText.Length-1
as in ASP.NET insted of
for i = 0 to ubound(aStr)
as in classic ASP
sorry I put
for i=0 to arrText.Length-1
as in ASP.NET insted of
for i = 0 to ubound(aStr)
as in classic ASP
<%
' this will crop a sentence
Function CropSentence(strText, intLength, strTrial)
If Len(strText) > intLength Then
CropSentence = Left(strText, intLength) & strTrial
Else
CropSentence = strText
End If
Proper(strText)
End Function
function Proper(str)
Proper = ucase(left(str,1)) & lcase(right(str,len(str)-1
end function
%>