求救一个很八卦的问题?

zyh791211 2004-12-11 09:29:18
在后台添加新闻后,前台显示标题和添加时间太长,有什么代码可以将标题多余几个字后省略号代替,还有时间用类似于04-10-05的方式代替呢?
送你50,别客气,拿走。不够再要~!
...全文
96 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
超级大笨狼 2004-12-12
  • 打赏
  • 举报
回复
left,year,day,month,right,mid...
这几个够了吧?
xuanhu 2004-12-12
  • 打赏
  • 举报
回复
我倒,标题可用 hackate(青羽兰心-------~兰心*-*寒~)
时间可用DateValue(rs("dateandtime"))具体函数使用方法在baidu里面可以搜到,
hackate 2004-12-12
  • 打赏
  • 举报
回复

now()
函数就可以的出你的结果了,为什么要那么麻烦,没必要吧!
zyh791211 2004-12-11
  • 打赏
  • 举报
回复
up~!
zyh791211 2004-12-11
  • 打赏
  • 举报
回复
函数怎么调用呢?
xiaoyuehen 2004-12-11
  • 打赏
  • 举报
回复
第一个问题: If + Left函数 + Len函数

第二个问题, 如果你的要求不高的话, 可以用DateValue(字段值)得到如2004-2-2的形式.如果需要04-02-02或02-02的格式的话, 最好还是写个函数.以下是个例子:
Function getBill_Code(intNum)
Dim str
str = "0000000" & intNum

getBill_Code = Right(str, Len(str))
End Function

几个 0 你可以自己设置, 这是我用来格式化单号的.
zyh791211 2004-12-11
  • 打赏
  • 举报
回复
<a href=news_view.asp?id=<%=rs("id")%> target=_blank><%=n_topic%></a>
zyh791211 2004-12-11
  • 打赏
  • 举报
回复
先谢楼上的,但我写的那个很好就是不起作用啊,着急!
zyh791211 2004-12-11
  • 打赏
  • 举报
回复
找到了:
function time_type(tvar,tt)
dim ttt,d_year,d_month,d_day,d_hour,d_minute,d_second
ttt=tvar
if ttt="" or isnull(ttt) then ttt=now_time
if not(isdate(ttt)) then
time_type=""
exit function
end if
d_year=year(ttt)
d_month=month(ttt)
if len(d_month)<2 then d_month="0"&d_month
d_day=day(ttt)
if len(d_day)<2 then d_day="0"&d_day
d_hour=hour(ttt)
if len(d_hour)<2 then d_hour="0"&d_hour
d_minute=minute(ttt)
if len(d_minute)<2 then d_minute="0"&d_minute
d_second=second(ttt)
if len(d_second)<2 then d_second="0"&d_second
select case tt
case 1 '2000-10-10 23:45:45
time_type=d_year&"-"&d_month&"-"&d_day&" "&d_hour&":"&d_minute&":"&d_second
case 11 '20001010234545
time_type=d_year&d_month&d_day&d_hour&d_minute&d_second
case 2 '年(4)-月-日 时:分:秒
time_type=d_year&"年"&d_month&"月"&d_day&"日 "&d_hour&"时"&d_minute&"分"&d_second&"秒"
case 3 '10-10 23:45
time_type=d_month&"-"&d_day&" "&d_hour&":"&d_minute
case 4 '2003-10-10
time_type=d_year&"-"&d_month&"-"&d_day
case 5 '2003年10月10日
time_type=d_year&"年"&d_month&"月"&d_day&"日"
case else
time_type=ttt
end select
end function

function code_js(strers,tt)
dim strer
strer=trim(strers)
if strer="" or isnull(strer) then
code_js=""
exit function
end if
if ishealth then
strer=code_health(strer)
end if
strer=replace(strer,"\","\\")
strer=replace(strer,chr(39),"'") '单引号
'strer=replace(strer,chr(39),"\'")
strer=replace(strer,chr(34),""") '双引号
'strer=replace(strer,chr(34),"\""")
select case tt
case 0
'strer=replace(strer,vbcrlf,"") '回车
strer=replace(strer,chr(10),"")
strer=replace(strer,chr(13),"")
case 1
'strer=replace(strer,vbcrlf,"\n") '回车
strer=replace(strer,chr(10),"\n")
strer=replace(strer,chr(13),"")
end select
if right(strer,1)="\" then
strer=strer&"n"
end if
code_js=strer
end function
——————————————————————————————————————
引用:
n_topic=code_js(n_topic,1)

n_tim=time_type(n_tim,1)
————————————————————
为什么不起作用呢》?


DARKNESSFALL 2004-12-11
  • 打赏
  • 举报
回复
楼主应该要的就是这个效果
hackate 2004-12-11
  • 打赏
  • 举报
回复
呵呵,我好笨哦,可以这样
<a href="xx.asp"><% if len(rs("bt"))>20 then%>left(rs("bt"),20)...<% else%>rs("bt")<%end if%></a>

不知道你是否满意,!

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧