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

保留 / 去除字符串内的数字

时 间:2014-06-28 12:11:01
作 者:在水一方   ID:20576  城市:沈阳
摘 要:使用循环函数建立自定义函数
正 文:

1.保留字符串内的数字

Function BLSZ(Str As Variant) As String

    Dim i, l As Integer
    Dim s As String
    l = Len(Str)       '字符串长度
    For i = 1 To l
        s = Mid(Str, i, 1)
        If s Like "[0-9]" Then
            BLSZ = BLSZ & s
        End If
    Next

End Function


2.去除字符串内数字

Function QCSZ(Str As Variant) As String
    Dim i, l As Integer
    Dim s As String
    l = Len(Str)       '字符串长度
    For i = 1 To l
        s = Mid(Str, i, 1)
        If Not(s Like "[0-9]" ) Then
            QCSZ = QCSZ & s
        End If
    Next
End Function


使用举例: 

更新表中的字段,去掉字段内容里面的数字

docmd.runsql " update 表 set 字段1 = QCSZ(字段1); "



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

常见问答:

技术分类:

相关资源:

专栏作家

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