Access开发培训
网站公告
·Access专家课堂QQ群号:151711184    ·Access快速开发平台下载地址及教程    ·欢迎加入Access专家课堂微信群!    ·如何快速搜索本站文章|示例|资料    
您的位置: 首页 > 技术文章 > Access数据库-模块/函数/VBA

英文标点符号替换成中文标点符号函数

时 间:2010-07-06 09:49:45
作 者:咱家是猫   ID:85  城市:广州
摘 要:英文标点符号替换成中文标点符号函数
正 文:

常规标点好办点,单引用与双引号有点困难

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
    '替换双引号
    N = 0: B = False
    L = Len(enTozhMark)
    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



Access软件网QQ交流群 (群号:54525238)       Access源码网店

常见问答:

技术分类:

相关资源:

专栏作家

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助