原创  CutString 字符串截除指定长度后的部分(考虑汉字字符串) 收藏

'------------------------------------------------
' 字符串截除指定长度后的部分(考虑汉字字符串)
' 用途:显示文章标题列表
' 自定义函数:StringLen
'------------------------------------------------
function CutString( tempstr, pnDispLen )
 
  dim cRet , nLoop
 if pnDispLen <= 0 then
   pnDispLen = 20
 end if
 if StringLen( tempstr ) > pnDispLen then
  cRet = ""
  nRetLen = 0
  nLoop = 1
  while nRetLen < pnDispLen
     if asc( mid( tempstr, nLoop, 1 ) ) < 0 then ' 汉字
        nRetLen = nRetLen + 2
     else        
        nRetLen = nRetLen + 1
     end if
     cRet = cRet + mid(tempstr,nLoop,1)
     nLoop = nLoop + 1   
  wend    
   CutString = cRet + "…"    
 else
  CutString = tempstr
 end if 
end function
 

发表于 @ 2007年05月18日 14:02:00 | 评论( loading... ) | 编辑| 举报| 收藏

旧一篇:StringLen 返回字符串的长度:字节数  | 新一篇:jBPM3.0中文用户指南.chm

  • 发表评论
  • 评论内容:
  •  
Copyright © ForestK
Powered by CSDN Blog