最新下载
热门教程
- 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
相关文章
- 金铲铲之战2024最新兑换码汇总大全 05-12
- 《浩劫前夕》攻略 简评+配置+下载 05-12
- 《夜族崛起》正式版最佳建家位置推荐 05-12
- 《夜族崛起》吸血鬼猎人位置介绍 05-12
- 《夜族崛起》新版本内容介绍 05-12
- 《非生物因素》制作食物方法 05-12