这并不是一项基本操作,VB好像没有。不过可以这样: function InsetNChar(byref strS as string,byval intI as integer,byval chrC as byte,byval intNum as integer) as integer '========================================== strs 要操作的字符串 intI 插入位置 chrC 插入的字符 intNum 插入的个数 '================ 返回:1 :操作正确 0 :错误 '========================================= dim tempS as string dim leftS as string,rightS as string dim lenS as integer lenS=len(strS) if intI>lens then InsertNchar=0 exit sub end if leftS=left(strS,intI) rightS=right(strS,lenb(strS)-intI) tempS=leftS+trim(string(chrC,intNum))+rightS strS=tempS InsertNchar=1 end function
Private Sub Command1_Click() s = "这是一个例子。" l = Len(s) For i = 2 To l * 2 Step 2 s = Left(s, i - 1) + Space(1) + Right(s, l - i / 2) Next s = Left(s, Len(s) - 1) Print s Print Len(s) End Sub
function InsetNChar(byref strS as string,byval intI as integer,byval chrC as byte,byval intNum as integer) as integer
'==========================================
strs 要操作的字符串
intI 插入位置
chrC 插入的字符
intNum 插入的个数
'================
返回:1 :操作正确
0 :错误
'=========================================
dim tempS as string
dim leftS as string,rightS as string
dim lenS as integer
lenS=len(strS)
if intI>lens then
InsertNchar=0
exit sub
end if
leftS=left(strS,intI)
rightS=right(strS,lenb(strS)-intI)
tempS=leftS+trim(string(chrC,intNum))+rightS
strS=tempS
InsertNchar=1
end function
s = "这是一个例子。"
l = Len(s)
For i = 2 To l * 2 Step 2
s = Left(s, i - 1) + Space(1) + Right(s, l - i / 2)
Next
s = Left(s, Len(s) - 1)
Print s
Print Len(s)
End Sub