请指点一段代码

wvtjplh 2009-10-02 12:15:09
'***********************************************
'去掉尺寸后面的数量
'***********************************************
Function Dimensions(num)
dim idArr,idArr2,y,yy,i
if instr(num,",")>0 then
idArr=split(num,",")
for yy = 0 to ubound(idArr)
idArr2=split(idarr(yy),"X")
for y= 0 to ubound(idArr2)
y=y+1
if y>3 then
Exit For
end if
if y=1 and yy=0 then
Dimensions=idarr2(y-1)
elseif y=1 and yy<>0 then
Dimensions=Dimensions&","&idarr2(y-1)
else
Dimensions=Dimensions&"X"&idarr2(y-1)
end if
'Response.Write num
next
next
else
Dimensions=num
end if
End Function


这段代码用来去掉尺寸后面的数量比如在尺寸栏中输入的是56X54.5X85X2(最后的X2代表的数量),38X38X76, 那么经过处理后腰显示为56X54.5X85,38X38X76该如何写?
如果要让输出变成 56X54.5X85X2(最后的X2代表的数量并显示红色),38X38X76 该如何写?
谢谢!

我自己写的这段代码把56X54.5X85X2,38X38X76 处理后变成了56X85,38X76 把数组中的第二个数省略掉了,不知道错在哪里?
...全文
66 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hookee 2009-10-02
  • 打赏
  • 举报
回复
数量显示为红色:

<%
Response.Write Dimensions("56X54.5X85X2,38X38X76")

Function Dimensions(num)
Dim a, b
a = Split(num, ",")
s = ""
For i=0 To UBound(a)
b = Split(a(i), "X")
If UBound(b) > 2 Then
t = ""
For j=0 To 2
t = t & b(j) & "X"
Next
t = Left(t, Len(t)-1)
s = s & t & "<span style='color:red;'>" & Right(a(i),Len(a(i))-Len(t)) & "</span>,"
Else
s = s & a(i) & ","
End If
Next
If s <> "" Then s=Left(s,Len(s)-1)
Dimensions = s
End Function
%>
hookee 2009-10-02
  • 打赏
  • 举报
回复

Function Dimensions(num)
Dim a, b
a = Split(num, ",")
s = ""
For i=0 To UBound(a)
b = Split(a(i), "X")
If UBound(b) > 2 Then
t = ""
For j=0 To 2
t = t & b(j) & "X"
Next
t = Left(t, Len(t)-1)
s = s & t & ","
Else
s = s & a(i) & ","
End If
Next
If s <> "" Then s=Left(s,Len(s)-1)
Dimensions = s
End Function
youhao1999 2009-10-02
  • 打赏
  • 举报
回复
帮顶
wvtjplh 2009-10-02
  • 打赏
  • 举报
回复
非常感谢!已经解决了!

28,406

社区成员

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

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