最新下载
热门教程
- 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
相关文章
- 逃离鸭科夫零号区技术高手任务怎么通过 技术高手任务流程攻略 10-30
- 三国群英传策定九州小乔阵容怎么搭配 10-30
- 漫威秘法狂潮灵蝶技能有哪些 10-30
- 原神雅珂达是什么类型角色-雅珂达角色定位介绍 10-30
- 洛克王国世界稀有宠物怎么获取 10-30
- 口袋斗罗大陆邪月强度如何 10-30