截取实际长度字符串并用空格替换

丶玩囍

丶玩囍

2016-02-19 12:29

岁数大了,QQ也不闪了,微信也不响了,电话也不来了,但是图老师依旧坚持为大家推荐最精彩的内容,下面为大家精心准备的截取实际长度字符串并用空格替换,希望大家看完后能赶快学习起来。

function cutstr(thestr,strlen)
dim l,t,c
l=len(thestr)
t=0
for dxy=1 to l
c=Abs(asc(Mid(thestr,dxy,1)))
if c255 then
t=t+2
else
t=t+1
end if
if t=strlen then
thev=left(thestr,dxy)
exit for
else
bu=strlen-t
for bui=1 to bu
strbu=" "
strbuall=strbuall&strbu
next
thev=thestr&strbuall
strbu=""
strbuall=""
end if
next
cutstr=thev
end function

%
'============================
'函数名w_cut(type,num)
'作用:字符串截取
'参数type,num
'type:字符串内容
'num:字符串被截取的长度
'=============================

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/webkaifa/)

Function w_cut(types,num)
  dim ctypes,cnum,ci,tt,tc,cc
  ctypes=types:cnum=int(num):w_cut="":tc=0:cc=0
  for ci=1 to len(ctypes)
    if cnum0 then w_cut=w_cut&"...":exit for
    tt=mid(ctypes,ci,1)
    if int(asc(tt))=0 then
      w_cut=w_cut&tt
      tc=tc+1:cc=cc+1
      if tc=2 then
        tc=0:cnum=cnum-1
      end if
      if cc5 then cnum=cnum-1:cc=0
    else
      cnum=cnum-1
      if cnum=0 then w_cut=w_cut&"...":exit for
      w_cut=w_cut&tt
    end if
  next
End Function

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/webkaifa/)

%

展开更多 50%)
分享

猜你喜欢

截取实际长度字符串并用空格替换

Web开发
截取实际长度字符串并用空格替换

截取固定长度字符串显示在页面

ASP
截取固定长度字符串显示在页面

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

检测含有中文字符串的实际长度

Web开发
检测含有中文字符串的实际长度

测字符串长度函数

ASP
测字符串长度函数

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

CSS:用overflow代替left截取指定长度字符串

Web开发
CSS:用overflow代替left截取指定长度字符串

正则替换字符串功能

Web开发
正则替换字符串功能

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

记录集内随机取记录的代码

记录集内随机取记录的代码

莪旳心 早已因迩千疮百孔 - QQ伤感分组

莪旳心 早已因迩千疮百孔 - QQ伤感分组
下拉加载更多内容 ↓