Office中国论坛/Access中国论坛
标题:
英文标点符号替换成中文标点符号的函数
[打印本页]
作者:
咱家是猫
时间:
2009-6-18 17:02
标题:
英文标点符号替换成中文标点符号的函数
Private Function enTozhMark(ReplaceStr As String) As String
'把传递进来的字符串中的英文标点符号替换成中文标点符号
'作者:咱家是猫 QQ:130036500
Const enStr As String = ",.?;:!()"
Const zhStr As String = ",。?;:!()"
Dim I As Byte, L As Integer, B As Boolean, N As Integer
enTozhMark = ReplaceStr
'替换常规标点符号
For I = 1 To 8
enTozhMark = Replace(enTozhMark, Mid(enStr, I, 1), Mid(zhStr, I, 1))
Next I
L = Len(enTozhMark)
'替换双引号
N = 0: B = False
For I = 1 To L
N = InStr(N + 1, enTozhMark, Chr(34))
If N <> 0 Then
I = N
If B = False Then
enTozhMark = Left(enTozhMark, N - 1) & "“" & Mid(enTozhMark, N + 1)
Else
enTozhMark = Left(enTozhMark, N - 1) & "”" & Mid(enTozhMark, N + 1)
End If
B = Not B
Else
Exit For
End If
Next I
'替换单引号
N = 0: B = False
For I = 1 To L
N = InStr(N + 1, enTozhMark, Chr(39))
If N <> 0 Then
I = N
If B = False Then
enTozhMark = Left(enTozhMark, N - 1) & "‘" & Mid(enTozhMark, N + 1)
Else
enTozhMark = Left(enTozhMark, N - 1) & "’" & Mid(enTozhMark, N + 1)
End If
B = Not B
Else
Exit For
End If
Next I
End Function
复制代码
作者:
heqing3000
时间:
2010-1-2 09:12
太好了
作者:
goto2008
时间:
2010-1-2 18:28
学习
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/)
Powered by Discuz! X3.3