最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
两个控制显示格式的函数(自动换行、自动省略)
时间:2022-06-30 11:18:38 编辑:袖梨 来源:一聚教程网
1)函数:rowscode()-----每行显示n个字母,自动换行
Function rowscode(str,n)
If len(str)<=n/2 Then
rowscode=str
Else
Dim TStr
Dim l,t,c
Dim i
l=len(str)
TStr=""
t=0
for i=1 to l
c=asc(mid(str,i,1))
If c<0 then c=c+65536
If c>255 then
t=t+2
Else
t=t+1
End If
TStr=TStr&(mid(str,i,1))
If t>n Then
TStr=TStr&"
"
t=0
End if
next
rowscode= TStr
End If
End Function
2)函数:lefttrue()-----如果字符串str的长度大于n,则显示左边的n个字符
Function LeftTrue(str,n)
If len(str)<=n/2 Then
LeftTrue=str
Else
Dim TStr
Dim l,t,c
Dim i
l=len(str)
TStr=""
t=0
for i=1 to l
c=asc(mid(str,i,1))
If c<0 then c=c+65536
If c>255 then
t=t+2
Else
t=t+1
End If
If t>n Then exit for
TStr=TStr&(mid(str,i,1))
next
LeftTrue = TStr & "…"
End If
End Function
Function rowscode(str,n)
If len(str)<=n/2 Then
rowscode=str
Else
Dim TStr
Dim l,t,c
Dim i
l=len(str)
TStr=""
t=0
for i=1 to l
c=asc(mid(str,i,1))
If c<0 then c=c+65536
If c>255 then
t=t+2
Else
t=t+1
End If
TStr=TStr&(mid(str,i,1))
If t>n Then
TStr=TStr&"
"
t=0
End if
next
rowscode= TStr
End If
End Function
2)函数:lefttrue()-----如果字符串str的长度大于n,则显示左边的n个字符
Function LeftTrue(str,n)
If len(str)<=n/2 Then
LeftTrue=str
Else
Dim TStr
Dim l,t,c
Dim i
l=len(str)
TStr=""
t=0
for i=1 to l
c=asc(mid(str,i,1))
If c<0 then c=c+65536
If c>255 then
t=t+2
Else
t=t+1
End If
If t>n Then exit for
TStr=TStr&(mid(str,i,1))
next
LeftTrue = TStr & "…"
End If
End Function
相关文章
- 卡厄思梦境亚服官网入口 卡厄思梦境官网链接 12-30
- beautybox汉化版免费下载安装最新版-beautybox官网正版下载中文版 12-30
- ARC Raiders我们在上面的据点任务完成攻略 12-30
- CS扫描全能王网页版入口-CS扫描全能王电脑版官网登录 12-30
- 天下万象势力演兵玩法有什么规则 12-30
- 斗罗大陆零天青牛蟒有什么玩法 12-30