For li_i = 1 To li_count
li_j = 0
li_width = 0
Do While li_width < iWidth
ls_tmp = Mid(sArg,li_begin + li_j)
If ls_tmp = '' Then exit
ls_1 = Left(ls_tmp,1)
If li_width > 0 And (ls_1 = '(' Or ls_1 = '(') Then
ls_2 = Right(ls_tmp,1)
If (ls_2 = ')' Or ls_2 = ')') And Len(ls_tmp) <= iWidth + 2 &
And li_width + Len(ls_tmp) > iWidth + 2 Then exit
End If
If (ls_1 >= '0' And ls_1 <= '9') Or ls_1 = '.' Then
li_num ++
Else
li_num = 0
End If
li_j ++
li_width = li_width + Len(ls_1)
Loop
//判断英文符号
ls_tmp = Mid(sArg,li_begin + li_j,1)
If ls_tmp = ',' Or ls_tmp = '.' Or ls_tmp = ')' &
Or ls_tmp = ',' Or ls_tmp = '。' Or ls_tmp = ')'Then li_j++
If li_num > 0 Then
If (ls_tmp >= '0' And ls_tmp <= '9') Or ls_tmp = '.' Then
li_j = li_j - li_num
End If
li_num = 0
End If
ls_return = ls_return + Mid(sArg,li_Begin,li_j)
If li_i <> li_count And Mid(sArg,li_Begin + li_j) <> '' Then
For li_1 = 1 To iCount
ls_return = ls_return + '~r~n'
Next
ElseIf li_width < iWidth - 2 And li_j <> 0 Then
ls_return = ls_return + Fill(' ',(iWidth - li_width) / 2)
End If
for i=1 to li_len
lch_char = mid(as_text,i,1)
if asc(lch_char) > 127 then
j++
k++
else
if lch_char = '~r' then
li_totalrow++
k++
ls_wrappedtext += mid(as_text,l,k)
j = 0
l += k
k =0
elseif lch_char = '~n' then //新行
k++
ls_wrappedtext += mid(as_text,l,k)
l +=k
k --
else
k++
end if
end if
if k >= ai_charincol then//如一行已超过最大长度,则自动折行
lch_next = mid(as_text,i+1,1)
ls_next = mid(as_text,i+1,2)
ls_prev = mid(as_text,i,2)
if lch_next = '~r' or lch_next = '~n' then
continue
elseif lch_next = '.' or lch_next =',' or lch_next ='?' or lch_next ='!' &
or lch_next =')' or lch_next =']' or lch_next ='}' or lch_next =';' &
or lch_next =':' or lch_next ='~'' or lch_next ='~"' then
if i <> li_len -1 then
continue
else
exit
end if
elseif ls_prev = ',' or ls_prev ='。' or ls_prev = '?' &
or ls_prev = '!' or ls_prev = '”' or ls_prev ='’' or &
ls_prev =')' or ls_prev = ';' or ls_prev = ':' or ls_prev = '、' then
if i <> li_len -1 then
continue
else
exit
end if
elseif ls_next = ',' or ls_next ='。' or ls_next = '?' &
or ls_next = '!' or ls_next = '”' or ls_next ='’' or &
ls_next =')' or ls_next = ';' or ls_next = ':' or ls_next = '、' then
if i <> li_len -2 then
j++
i++
k++
continue
else
exit
end if
else
if mod(j,2) = 0 then
ls_wrappedtext = ls_wrappedtext + mid(as_text,l,k) + '~r~n'
else
ls_string = mid(as_text,l,k -1)
ls_wrappedtext = ls_wrappedtext + mid(as_text,l,k -1) + '~r~n'
i --
k --
end if
j = 0
l += k
k = 0
li_totalrow ++
end if
end if
next